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 notificatio开发者_如何学Pythonn 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
精彩评论