相关疑难解决方法(0)

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;

NotificationManager nm =
            (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationItem.notificationID, notification);
Run Code Online (Sandbox Code Playgroud)

nm.notify引发了异常

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

notifications android push android-4.2-jelly-bean

32
推荐指数
3
解决办法
2万
查看次数