java.lang.SecurityException:需要对 Jelly Bean 4.2 的 VIBRATE 权限 [英] java.lang.SecurityException: Requires VIBRATE permission on Jelly Bean 4.2

查看:17
本文介绍了java.lang.SecurityException:需要对 Jelly Bean 4.2 的 VIBRATE 权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从昨天开始,当我收到推送通知时,我在 Android 4.2 上遇到了一个问题,即使我没有将其设置为振动,也需要获得许可

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;通知管理器 nm =(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);nm.notify(notificationItem.notificationID,通知);

异常由 nm.notify 引发

我在两个不同的应用程序中遇到了这个问题,我从不修改代码

解决方案

这是 Android 4.2 中由于通知振动策略更改而导致的错误;4.2.1 中的此更改修复了权限错误.>

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);

the exception is raised by nm.notify

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

解决方案

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.

这篇关于java.lang.SecurityException:需要对 Jelly Bean 4.2 的 VIBRATE 权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆