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

后端 未结 2 503
有刺的猬
有刺的猬 2020-12-11 02:36

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

相关标签:
2条回答
  • 2020-12-11 02:50

    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.

    0 讨论(0)
  • 2020-12-11 03:06

    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

    0 讨论(0)
提交回复
热议问题