Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 本地通知导致安全异常_Java_Android_Securityexception_Android Securityexception - Fatal编程技术网

Java 本地通知导致安全异常

Java 本地通知导致安全异常,java,android,securityexception,android-securityexception,Java,Android,Securityexception,Android Securityexception,我制作了一个方法,当进度加载完成时发送一个本地通知,当我构建应用程序时,没有任何错误/警告,我在发布Google console崩溃报告后收到了这些错误/警告 以下是通知方法: public void notif() { final int NOTIFICATION_ID = 1; int icon = getIcon(); String provx = getProv(); NotificationCompat.Builder mBuilder = new

我制作了一个方法,当进度加载完成时发送一个本地通知,当我构建应用程序时,没有任何错误/警告,我在发布Google console崩溃报告后收到了这些错误/警告

以下是通知方法:

public void notif() {

    final int NOTIFICATION_ID = 1;
    int icon = getIcon();
    String provx = getProv();

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
    Notification notification = mBuilder
            .setSmallIcon(icon)               
            .setVibrate(new long[]{1000, 1000})
            .setLights(Color.BLUE, 700, 500)
            .setContentTitle("New notification!")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(provx))
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentText(provx)
            .build();

    NotificationManager nMN = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nMN.notify(NOTIFICATION_ID, notification); //here where I got the error
}
java.lang.SecurityException: 
   at android.os.Parcel.readException (Parcel.java:1425)
   at android.os.Parcel.readException (Parcel.java:1379)
   at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag (INotificationManager.java:246)
   at android.app.NotificationManager.notify (NotificationManager.java:135)
   at android.app.NotificationManager.notify (NotificationManager.java:111)
   at com.dev.days.myapp.Splash.notif (Splash.java:184)
   at com.dev.days.myapp.Splash$1.run (Splash.java:151)
   at java.lang.Thread.run (Thread.java:856)
这是崩溃日志:

public void notif() {

    final int NOTIFICATION_ID = 1;
    int icon = getIcon();
    String provx = getProv();

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
    Notification notification = mBuilder
            .setSmallIcon(icon)               
            .setVibrate(new long[]{1000, 1000})
            .setLights(Color.BLUE, 700, 500)
            .setContentTitle("New notification!")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(provx))
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setContentText(provx)
            .build();

    NotificationManager nMN = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nMN.notify(NOTIFICATION_ID, notification); //here where I got the error
}
java.lang.SecurityException: 
   at android.os.Parcel.readException (Parcel.java:1425)
   at android.os.Parcel.readException (Parcel.java:1379)
   at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag (INotificationManager.java:246)
   at android.app.NotificationManager.notify (NotificationManager.java:135)
   at android.app.NotificationManager.notify (NotificationManager.java:111)
   at com.dev.days.myapp.Splash.notif (Splash.java:184)
   at com.dev.days.myapp.Splash$1.run (Splash.java:151)
   at java.lang.Thread.run (Thread.java:856)

正如上面@Adam S所建议的,通过在
清单
文件中添加
振动
权限,可以简单地解决这个问题

<uses-permission android:name="android.permission.VIBRATE" />

您是否持有许可证?否,是否有使用振动的许可证?如果是,请提供