Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android通知灯不工作_Android_Android Notifications - Fatal编程技术网

Android通知灯不工作

Android通知灯不工作,android,android-notifications,Android,Android Notifications,我使用通知让用户知道服务仍在运行。现在我想使用notificationlight来提醒用户。(因为它很花哨) 通知工作正常,但通知灯不起任何作用。其他应用程序可以很好地使用通知灯(gtalk、facebook) 这或多或少是添加了以下标志的通知示例代码: notification.ledARGB = 0xff00ff00; notification.ledOnMS = 100; notification.ledOffMS = 100; notification.flags |= Notifica

我使用通知让用户知道服务仍在运行。现在我想使用notificationlight来提醒用户。(因为它很花哨)

通知工作正常,但通知灯不起任何作用。其他应用程序可以很好地使用通知灯(gtalk、facebook)

这或多或少是添加了以下标志的通知示例代码:

notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 100;
notification.ledOffMS = 100;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;

notification.flags |= Notification.FLAG_NO_CLEAR + Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(NOTIFICATION_ID, notification);

相反,这也不起作用

我正在用安卓4.0调试Galaxy Nexus,但该应用的目标是安卓2.3.3

编辑:
这可能是许可的问题吗?如果是,哪一个?我查看了所有内容,发现通知灯没有匹配的权限。

我认为+运算符有错误,您需要OR:

notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
编辑:如果您使用的是标志,我认为正确的应该是:

notification.flags |= Notification.FLAG_SHOW_LIGHTS

在jelly bean设备上,led仅在通知优先级设置为max或default时工作,请再次检查。下面的代码片段在jb设备上运行良好

notification.setLights(0xFF0000FF,100,3000);
notification.setPriority(Notification.PRIORITY_DEFAULT);
在这里,我显示了蓝色led的通知,它将保持100毫秒,关闭3000毫秒,直到用户解锁他的设备


并检查您是否使用NotificationCompat(compatibility)类而不是ignore setDefaults方法并使用SetLight、SetSound、Setvibration等

强制“您确定您对通知灯有正确的权限”好问题,我得到了吗?仍然不起作用。。。文档中没有列出lightMy Error所需的任何权限——您不需要此权限。我会尝试将ARGB设置为ffffffff,看看这是否会有不同。刚才试过了,没有变化。这不是错误,这是一个特性!这些是要设置的位,加号可以正常工作。因为每一面旗都是另一个位,所以你永远不会得到一个结转。但是手术室工作得很好。如您在上部代码块中看到的,根据文档,如果使用默认的\u LIGHTS标志,则不需要设置标志\u SHOW \u LIGHTS。
notification.setLights(0xFF0000FF,100,3000);
notification.setPriority(Notification.PRIORITY_DEFAULT);