简体   繁体   中英

Android programming. Vibration/LED light Function

Hi I have created a task reminder application. For example, you select a time of when to be reminded of a certain task, when that time comes, a notification comes up on the status bar.

However I would like to implement a vibrating function and possibly an LED light function with the notification but I am not sure where to start? Does anyone know?

Thanks.

Have you looked at the Notification documentation? To set the led and have the phone vibrate, all you need to do is set the defaults field with the DEFAULT_LIGHTS and DEFAULT_VIBRATE values ORed together.

notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE;

If you already have the code for creating and displaying the notification, the next lines of code will do:

notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;

More details can be found here .

Just quick google search Creating Status Bar Notifications http://developer.android.com/guide/topics/ui/notifiers/notifications.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM