Languages

Menu
Sites
Language
vibration is not working
int error, num;
error = device_haptic_get_count(&num);
haptic_device_h handle;
haptic_effect_h effect_handle;
error = device_haptic_open(0, &handle);
error = device_haptic_vibrate(handle, 1000, 1000, &effect_handle);

hello,

This is my code I learned this from haptic(not vibration) guide at the below link:

https://developer.tizen.org/documentation/guides/native-application/system/device

 

But my Z1 device is not vibrating at all,

Is there anyone who succesfully vibrate Z1 device in native app?

 

 

View Selected Answer

Responses

7 Replies
Palitsyna
Xaemin Cho

Yes, I already added this

<privileges>
    <privilege>http://tizen.org/privilege/systemsettings</privilege>
    <privilege>http://tizen.org/privilege/haptic</privilege>
</privileges>

 

Mark as answer
Xaemin Cho

I got answer by myself

 

The 3rd parameter means level of vibration.

It should be ranged from 0 to 100.

My Z1 is vibrating now when I set this value under 100.

 

 

colin Rao

Hi,

Strange!!!

My Z1 no working. What's wrong in my code, or am I mis-understand?

Sample code:

haptic_device_h handle;
haptic_effect_h effect_handle;
int error, num;
error = device_haptic_get_count(&num);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_get_count] num:%d, error:%d",num,error);

error = device_haptic_open(0, &handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_open] error:%d",error);
error = device_haptic_vibrate(handle, 5000, 99, &effect_handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_vibrate] error:%d",error);
error = device_haptic_stop(handle, effect_handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_stop] error:%d",error);
error = device_haptic_close(handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_close] error:%d",error);

Dlog:

07-13 17:10:39.430 : INFO / test ( 16633 : 16633 ) : [device_haptic_get_count] num:1, error:0
07-13 17:10:39.440 : INFO / test ( 16633 : 16633 ) : [device_haptic_open] error:0
07-13 17:10:39.440 : INFO / test ( 16633 : 16633 ) : [device_haptic_vibrate] error:0
07-13 17:10:39.440 : INFO / test ( 16633 : 16633 ) : [device_haptic_stop] error:0
07-13 17:10:39.440 : INFO / test ( 16633 : 16633 ) : [device_haptic_close] error:0

 

Xaemin Cho

Hi, you can check 2 things,

 

1. Did you add proper privilege into Manifest like this?

    <privileges>
     <privilege>http://tizen.org/privilege/haptic</privilege> 
    </privileges>

 

2. Do not call stop API right after vibrate API.

   In my case, I didn't call device_haptic_stop and device_haptic_close for testing.

colin Rao

Hi,

thanks a lot, it's works fine! :)

haptic_device_h handle;
haptic_effect_h effect_handle;
int error;

error = device_haptic_open(0, &handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_open] error:%d",error);
error = device_haptic_vibrate(handle, 5000, 99, &effect_handle);
dlog_print(DLOG_INFO, LOG_TAG, "[device_haptic_vibrate] error:%d",error);

 

pius lee

What are you guys doing in this thread?

Anyway, 

Did you check the main loop?

device_haptic_vibrate is not blocking function, maybe It use mainloop internally.

So If your application doesn't have mainloop, this function doesn't work.

And if you call not it in main thread, (if you call it in another thread) I think it should be not working.

I don't have real Z1 device, and emulator don't have vibrator. so I can't test it. but I think it's almost be right.