Change “Pulse notification light” / trackball light setting on Android (Nexus One only?)

不羁岁月 提交于 2019-11-30 18:17:12

问题


On the Nexus One (at least in 2.1-update1, and I think in 2.1), there is a setting under Sound & Display: "Pulse notification light". This doesn't seem to be present on the "2.1 with Google APIs" emulator image. I've not yet checked any other devices.

Pulse notification light: Pulse trackball light repeatedly for new notifications http://chris.boyle.name/images/20100206-pulse-trackball.png

I want to set this programmatically without user interaction, in order to make a Locale plugin, so the device can grab my attention when I'm awake at my desk, without having it floodlighting the room when someone spams me at 4am. It's quite bright.

I didn't see it in android.provider.Settings.System where many other things on this screen live, so I had a look in the platform source. There are some relevant parts in NotificationManagerService, in enqueueNotificationWithTag and updateLightsLocked. That goes off into HardwareService which seems well past the point of caring about user settings. I've no idea where this setting is implemented or how I might influence it.

I fully expect the answer to be "there is no API for this" (perhaps related to it being Nexus One specific), and that the best I can do is to schedule (using Locale or something else) an Intent of ACTION_DISPLAY_SETTINGS to remind me to set the box manually, which would suck. I'm hoping that I've missed something, or that a Googler is reading this and can tell me that this is planned for addition to the API?


回答1:


I know I'm going to die painfully for using an undocumented API (or rather, undocumented system setting name), but here is the magic line:

android.provider.Settings.System.putInt(context.getContentResolver(),
        "notification_light_pulse", on ? 1 : 0);

Found using sqlite3 on my own device.

Here is this solution in a convenient Locale plugin: http://chris.boyle.name/projects/ptlp



来源:https://stackoverflow.com/questions/2211543/change-pulse-notification-light-trackball-light-setting-on-android-nexus-on

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