简体   繁体   English

Android 编程。 振动/LED灯 Function

[英]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.例如,您 select 某个时间需要提醒某个任务,当该时间到来时,状态栏上会出现通知。

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?但是我想实现一个振动 function 和可能的 LED 灯 function 通知,但我不知道从哪里开始? 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.要设置 LED 并让手机振动,您需要做的就是将默认字段与DEFAULT_LIGHTSDEFAULT_VIBRATE值 ORed 一起设置。

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只需快速谷歌搜索创建状态栏通知http://developer.android.com/guide/topics/ui/notifiers/notifications.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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