java.lang.SecurityException:需要对 Jelly Bean 4.2 的 VIBRATE 权限

编程入门 行业动态 更新时间:2024-10-18 08:31:18
本文介绍了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 权限

本文发布于:2023-11-27 04:07:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636523.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:权限   SecurityException   lang   java   Jelly

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!