另类操作系统 三星Tizen2.4测试版SDK已经向开发者推送下载
从本篇文章中,你将会了解到如何下载、安装并使用三星Tizen2.4测试版SDK进行开发。
下载
- 访问三星的开发者网站(https://developer.tizen.org/development/sdk/download)。
- 在“Tizen Studio”页面选择合适的平台进行下载,Windows、macOS和Ubuntu都可下载,这里以Windows为例。
- 点击下载链接,等待下载完成。
安装
- 双击下载的安装程序,按照提示进行安装。
- 安装完后启动Tizen Studio。
创建新项目
- 启动Tizen Studio后,点击“File” -> “New” -> “Tizen Project” -> “Tizen Wearable 2.3 Native Application”。
- 在弹出的对话框中填写项目信息,例如应用名称、包名、版本号等。
- 点击“Finish”进行创建。
运行项目
- 点击“Run” -> “Tizen Emulator Manager”,在弹出的窗口中创建一个新的模拟器。
- 选择所要运行的模拟器,点击“Run”进行运行。
- 在模拟器中选择你创建的项目并运行。
示例 1
下面通过一个简单的示例代码来展示在Tizen Studio中如何编写一个简单的应用:
#include <app.h>
#include <Elementary.h>
int main(int argc, char *argv[]) {
ui_app_lifecycle_callback_s event_callback = {0,};
app_event_handler_h handlers[5] = {NULL, };
int ret;
ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, app_event_callback, &event_callback);
ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, app_event_callback, &event_callback);
ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, app_event_callback, &event_callback);
ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, app_event_callback, &event_callback);
ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, app_event_callback, &event_callback);
event_callback.create = create_cb;
event_callback.terminate = terminate_cb;
event_callback.pause = pause_cb;
event_callback.resume = resume_cb;
event_callback.app_control = app_control_cb;
event_callback.ui_app_lang_changed = ui_app_lang_changed_cb;
event_callback.ui_app_orient_changed = ui_app_orient_changed_cb;
event_callback.ui_app_region_changed = ui_app_region_changed_cb;
ret = ui_app_main(argc, argv, &event_callback, NULL);
if (ret != APP_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
}
return ret;
}
static bool create_cb(void *data) {
ui_app_lifecycle_callback_s *callbacks = data;
/* Hook to take necessary actions before main event loop starts
Initialize UI resources
Open a connection to the sensor manager
Register callbacks for sensor events if it is necessary
*/
return true;
}
static void terminate_cb(void *data) {
/* Release all resources. */
}
static void pause_cb(void *data) {
/* Take necessary actions when application becomes invisible. */
}
static void resume_cb(void *data) {
/* Take necessary actions when application becomes visible. */
}
static void app_control_cb(app_control_h app_control, void *data) {
/* Handle the launch request. */
}
static void ui_app_lang_changed_cb(app_event_info_h event_info, void *user_data) {
/* APP_EVENT_LANGUAGE_CHANGED */
char *locale = NULL;
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
elm_language_set(locale);
free(locale);
}
static void ui_app_orient_changed_cb(app_event_info_h event_info, void *user_data) {
/* APP_EVENT_DEVICE_ORIENTATION_CHANGED */
}
static void ui_app_region_changed_cb(app_event_info_h event_info, void *user_data) {
/* APP_EVENT_REGION_FORMAT_CHANGED */
}
示例 2
下面通过一个简单的图形化界面来展示如何在Tizen Studio中创建一个简单的用户界面:
#include <app.h>
#include <Elementary.h>
enum {
SQUARE = 0,
CIRCLE = 1,
RECTANGLE = 2,
ITEM_LAST,
};
static const char *_icon_path[] = {
"images/ico_square.png",
"images/ico_circle.png",
"images/ico_rectangle.png",
};
typedef struct appdata {
Evas_Object *win;
Evas_Object *conform;
Evas_Object *layout;
Evas_Object *list;
} appdata_s;
static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) {
ui_app_exit();
}
static void item_selected_cb(void *data, Evas_Object *obj, void *event_info) {
appdata_s *ad = data;
int index = (int)elm_object_item_data_get(event_info);
switch (index) {
case SQUARE:
dlog_print(DLOG_INFO, "mytag", "Square is selected!");
break;
case CIRCLE:
dlog_print(DLOG_INFO, "mytag", "Circle is selected!");
break;
case RECTANGLE:
dlog_print(DLOG_INFO, "mytag", "Rectangle is selected!");
break;
default:
break;
}
}
static void create_base_gui(appdata_s *ad) {
/* Window */
elm_config_use_sync_set(EINA_TRUE);
ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
elm_win_autodel_set(ad->win, EINA_TRUE);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
/* Conformant */
ad->conform = elm_conformant_add(ad->win);
evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win, ad->conform);
evas_object_show(ad->conform);
/* Create a list view */
ad->list = elm_list_add(ad->conform);
evas_object_show(ad->list);
elm_list_item_append(ad->list, "Square", NULL, NULL, item_selected_cb, ad);
elm_list_item_append(ad->list, "Circle", NULL, NULL, item_selected_cb, ad);
elm_list_item_append(ad->list, "Rectangle", NULL, NULL, item_selected_cb, ad);
/* Layout */
ad->layout = elm_layout_add(ad->conform);
elm_layout_theme_set(ad->layout, "layout", "application", "default");
evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(ad->conform, ad->layout);
elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->list);
/* Show window */
evas_object_show(ad->win);
}
int main(int argc, char *argv[]) {
appdata_s ad = {NULL,};
ui_app_lifecycle_callback_s event_callback = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
app_event_handler_h handlers[5] = {NULL, };
int ret = 0;
/* Hook to take necessary actions before main event loop starts
Initialize UI resources
Open a connection to the sensor manager
Register callbacks for sensor events if it is necessary
*/
//create_base_gui(&ad);
create_base_gui(&ad);
ret = ui_app_main(argc, argv, &event_callback, &ad);
/* Hook to take necessary actions before main event loop starts
Release all resources
*/
return ret;
}
以上就是下载、安装和使用Tizen Studio开发三星Tizen2.4测试版SDK的完整攻略,通过这些步骤,你可以轻松上手开发Tizen应用。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:另类操作系统 三星Tizen2.4测试版SDK已经向开发者推送下载 - Python技术站