Android 2.2何时NotificationManager.notify()
需要WAKE_LOCK
权限?
我从一位用户那里收到了以下堆栈跟踪:
java.lang.SecurityException: Neither user ***** nor current process has android.permission.WAKE_LOCK.
at android.os.Parcel.readException(Parcel.java:1247)
at android.os.Parcel.readException(Parcel.java:1235)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:274)
at android.app.NotificationManager.notify(NotificationManager.java:118)
at android.app.NotificationManager.notify(NotificationManager.java:94)
...
更新Scala中的调用代码:
notification = new Notification(android.R.drawable.stat_notify_sync,
"%s %s".format(statusTitle, finishedStatus), 0)
notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL
notification.setLatestEventInfo(SyncService.this, statusTitle, finishedStatus,
PendingIntent.getActivity(SyncService.this, 0, new Intent(SyncService.this, classOf[MainActivity]), 0))
notificationManager.notify(NOTIFICATION, notification)