java.lang.SecurityException异常:要求在果冻豆4.2 VIBRATE许可果冻、异常、SecurityException、java

2023-09-04 12:27:50 作者:冷月醉夕阳

从昨天开始我已经在Android 4.2的一个问题,当我收到推送通知它需要即使我不把它设置为振动许可

Since yesterday I have an issue on Android 4.2 when I receive push notifications it requires the permission even if i don't set it to vibrate

Notification notification = new Notification(icon, notificationItem.message, when);
notification.setLatestEventInfo(context, "App", notificationItem.message,
            PendingIntent.getActivity(context, 0, intent, 0));
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;

NotificationManager nm =
            (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationItem.notificationID, notification);

异常被上调nm.notify

the exception is raised by nm.notify

我有这个问题,在两个不同的应用程序,我从来没有修改code

I have this issue in two different apps and i never modify the code

推荐答案

这是安卓4.2的一个错误是由于在通知振动政策的改变;许可错误是固定由这种变化 4.2.1。

This was a bug in Android 4.2 due to a change in the notification vibration policy; the permission bug was fixed by this change in 4.2.1.