Can the Android handset LED be manipulated without using a Notification object?

a 夏天 提交于 2019-12-17 20:05:40

问题


I want to control the LED on an Android device with more control than is offered by the Notification class. Notifications allow you to change the rate of flashing; e.g. 300 milliseconds on, 1000 milliseconds off, but that's it.

Essentially, I would like to turn the LED on and off at will at arbitrary times. Does anyone know if this is possible? The API does not seem to say so. Does it depend on the specific hardware?


回答1:


I haven't tried this in code, but the SDK shows this:

  • To turn the LED off, pass 0 in the alpha channel for colorARGB or 0 for both ledOnMS and ledOffMS.
  • To turn the LED on, pass 1 for ledOnMS and 0 for ledOffMS.
  • To flash the LED, pass the number of milliseconds that it should be on and off to ledOnMS and ledOffMS.

And then you could use NotificationManager.cancel() to arbitrarily turn the notification off.

http://developer.android.com/reference/android/app/Notification.html#FLAG_SHOW_LIGHTS




回答2:


You should be able to do this with a notification. You can raise and cancel the led using the notification manager and you could use the alarm manager part of android to control the arbitary times.



来源:https://stackoverflow.com/questions/1122570/can-the-android-handset-led-be-manipulated-without-using-a-notification-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!