SecurityException:获取应用程序信息:用户1010069和当前进程都没有android.permission.INTERACT_ACROSS_USERS

时间:2016-11-21 08:54:49

标签: android android-permissions android-multiple-users

我得到了这个奇怪的崩溃。似乎AlarmManager.set()导致了这一点 但我不明白是怎么回事。

堆栈追踪:

Fatal Exception: java.lang.RuntimeException: Unable to create application com.rotem.appmanager.app.MainApplication: java.lang.SecurityException: get application info: Neither user 1010069 nor current process has android.permission.INTERACT_ACROSS_USERS.
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4560)
       at android.app.ActivityThread.access$1500(ActivityThread.java:151)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5258)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:974)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
Caused by java.lang.SecurityException: get application info: Neither user 1010069 nor current process has android.permission.INTERACT_ACROSS_USERS.
       at android.os.Parcel.readException(Parcel.java:1546)
       at android.os.Parcel.readException(Parcel.java:1499)
       at android.app.IAlarmManager$Stub$Proxy.set(IAlarmManager.java:215)
       at android.app.AlarmManager.setImpl(AlarmManager.java:409)
       at android.app.AlarmManager.set(AlarmManager.java:208)
       at com.rotem.appmanager.app.DailyAppTasksHelper.scheduleNextDailyAlarm(SourceFile:81)

代码:

    Context context = MainApplication.getAppContext();

    Intent intent = new Intent(context, PrepareAppService.class);

    PendingIntent pendingIntent = PendingIntent.getService(context, CommonConfig.PendingIntentRequestCodes.ALARM_SCHEDULE_SELF_UPDATE, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    // cancel any existing alarms
    alarmManager.cancel(pendingIntent);

    // Set the alarm to start at approx. 14:00
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.add(Calendar.DATE, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 14);

    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
`

我不想添加此权限。

如何引起/复制?

1 个答案:

答案 0 :(得分:-3)

您必须将其用于某些安全级别。 Check this link,可能会帮助你