Languages

Menu
Sites
Language
Control screen rotation through API

Hi All,

I am writing an app which needs to control the screen auto rotation through API.

Is there any APIs available to manage screen auto rotation(ON/OFF).

I am using Tizen SDK 2.4.

Thank you.

Edited by: Dharmesh Guna on 19 Nov, 2015

Responses

2 Replies
Alex Dem

Hi,
Standart code for auto rotation support is in any native UI app:
 

if (elm_win_wm_rotation_supported_get(ad->win)) {
    int rots[4] = { 0, 90, 180, 270 };
    elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
}

You could try to add 2 rotations (for example) 
int rots[2] = { 0, 90 }; It will support portrait & reverse landscape orientations in this case.
Alexey.

Alex Dem

Also fyi:

To detect current orientation you could:
1) add callback on rotation changed
    evas_object_smart_callback_add(ad->win, "wm,rotation,changed", win_rotation_changed, ad);

and detect current rotation inside callback this way:

static void win_rotation_changed(void *data, Evas_Object *obj, void *event_info)
{
   appdata_s *ad = data;
   int current_degree = elm_win_rotation_get(obj);
}


2) Use system event APP_EVENT_DEVICE_ORIENTATION_CHANGED into your app . It is registered in any UI sample already

see:
ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);

You could extract current orientation inside app_event_cb :

static void ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
    app_device_orientation_e  orientation;
    int error =    app_event_get_device_orientation  (event_info, &orientation);
        //...
    return;
}

Alexey.