Upload
meoluoixauxi
View
226
Download
0
Embed Size (px)
Citation preview
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
1/21
Tizen DevelopmentApplication
Hanoi University of Science and
Technology
Hoang Van [email protected]
Tr!"ng #$i h%c Bch Khoa H N&iHanoi University of Science and Technology
HUST 2015
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
2/21
Application Framework
!Application fundamentals
! Badges
!
Bundles
!
Data Controls
STP@2015 2
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
3/21
Application Framework
!Application fundamentals:
! Start or exit the main event loop
! Register callbacks for application states
change events! Register callbacks for basic system events
! Get information about the application
STP@2015 3
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
4/21
Start/Exit the main event loop
! Start Main event loop
!
Exit Main event loop
STP@2015 4
ui_app_main (int argc, char **argv, ui_app_lifecycle_callback_s*callback, void *user_data)
ui_app_exit(void)
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
5/21
Register callbacks for app states
STP@2015 5
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
6/21
Register callbacks for system events
STP@2015 6
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
7/21
Get information about application
! Get current orientation of device
! Get the internal and external sharedfolders
!
STP@2015 7
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
8/21
Application states change
STP@2015 8
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
9/21
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
10/21
Launching Applications
!An application can be launched from thelauncher or from another application.
! Two methods to launch an application
! Explicit launch: launch an application withapplication id
! Implicit launch: launch an application with an
operation, URI, or MIME type.
STP@2015 10
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
11/21
Explicit launch an application
STP@2015 11
#include #include
#define TAG "MY_TAGapp_control_h app_control;app_control_create(&app_control);app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
app_control_set_app_id(app_control, "org.tizen.calculator");if (app_control_send_launch_request(app_control, NULL, NULL) ==APP_CONTROL_ERROR_NONE)
{
dlog_print(DLOG_INFO, TAG, "Succeeded to launch a calculator app.");}
else{
dlog_print(DLOG_ERROR, TAG, "Failed to launch a calculator app.");
}
app_control_destroy(app_control);
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
12/21
Explicit launch an application
! Exercise! Create a new application that has a button
(named Launch an application)
! When user clicks on the button "launchanother application (E.g., launch the HelloWorldapplication)
STP@2015 12
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
13/21
Explicit launch an application
! Exercise! Does your app run properly?
! Could you call another app from your app?
! What error code did you get?
STP@2015 13
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
14/21
To launch an application
! In the Caller Application! Declare the launch privilege!
http://tizen.org/privilege/appmanager.launch
! In the Callee (Target) Application!
Declare the launch privilege! http://tizen.org/privilege/appmanager.launch
! Export the app control operation
! Example:!
STP@2015 14
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
15/21
Implicit launch an application
! Only 3 data categories are used to determinewhich application can be launched:Operation, URI, and MIME type
! The application launcher framework scansthe installed applications to find applicationswhere 3 categories are exactly matched.
! If only 1 application is matched with 3 categories"It will be launched
! If more than 1 matched application are found "the application selector are showed.
STP@2015 15
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
16/21
Implicit launch an application
STP@2015 16
#include #include
#define TAG "MY_TAG"
app_control_h app_control;app_control_create(&app_control);
app_control_set_operation(app_control,APP_CONTROL_OPERATION_CREATE_CONTENT);app_control_set_mime(app_control, "image/jpg");if (app_control_send_launch_request(app_control, NULL, NULL) ==
APP_CONTROL_ERROR_NONE){
dlog_print(DLOG_INFO, TAG, "Succeeded to launch a viewer app.");}else
{dlog_print(DLOG_ERROR, TAG, "Failed to launch a viewer app.");
}app_control_destroy(app_control);
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
17/21
Implicit launch an application
STP@2015 17
#include #include
#define TAG "MY_TAG
app_control_h app_control;app_control_create(&app_control);
app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);app_control_set_uri(app_control, "file:///home/myhome/Photos/1_photo.jpg");app_control_set_mime(app_control, "image/*");if (app_control_send_launch_request(app_control, NULL, NULL) ==
APP_CONTROL_ERROR_NONE){
dlog_print(DLOG_INFO, TAG, "Succeeded to launch a viewer app.");}else
{dlog_print(DLOG_ERROR, TAG, "Failed to launch a viewer app.");
}app_control_destroy(app_control);
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
18/21
Implicit launch an application
STP@2015 18
#include #include
#define TAG "MY_TAG"
app_control_h app_control;app_control_create(&app_control);
app_control_set_operation(app_control,APP_CONTROL_OPERATION_CREATE_CONTENT);app_control_set_mime(app_control, "text/plain");if (app_control_send_launch_request(app_control, app_control_result, NULL) ==
APP_CONTROL_ERROR_NONE){
dlog_print(DLOG_INFO, TAG, "Succeeded: the application is launched.");}else
{dlog_print(DLOG_ERROR, TAG, "Failed to launch an application.");
}app_control_destroy(app_control);
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
19/21
Implicit launch an application
STP@2015 19
static void app_control(app_control_h app_control, void* user_data){
struct appdata *ad = (struct appdata *)user_data;char *operation, *mime, *app_id;
app_control_h reply;
app_control_get_operation(app_control, &operation);if (!strcmp(operation, APP_CONTROL_OPERATION_CREATE_CONTENT)){
app_control_get_mime(app_control, &mime);
if (!strcmp(mime, "text/plain")){
app_control_create(&reply);app_get_app_id(&app_id);app_control_add_extra_data(reply, APP_CONTROL_DATA_SELECTED, app_id);
app_control_reply_to_launch_request(reply, app_control,APP_CONTROL_RESULT_SUCCEEDED);
app_control_destroy(reply);}
}}
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
20/21
Badges
!A badge is an image displayed on theapplication icon
STP@2015 20
8/9/2019 HiepHV STP Tizen Chap 3 Application Framework
21/21
To be continued
STP@2015 21