7

I'm getting this weird crash. It seems like AlarmManager.set() cause this but I don't understand how nor why.

Stack trace:

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)

The code:

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

I don't want to the add this permission.

How can this be caused/reproduced?

Rotem Matityahu
  • 325
  • 5
  • 16
  • It is signature level permission. So you should add `android:protectionLevel="signature"` in manifest file and if your target API is `23` then you should use run time permission. – Piyush Nov 21 '16 at 09:00
  • Your code looks pretty harmless. Maybe something else in your project is causing the problem. Check out [this post](http://stackoverflow.com/questions/20578474/permission-denial-this-requires-android-permission-interact-across-users-full): several other developers experienced this behavior for very different reasons and managed to fix it one way or the other. – Bö macht Blau Nov 21 '16 at 09:33

1 Answers1

-3

You have to use it for some security level. Check this link, May be it will help you

Community
  • 1
  • 1
Ready Android
  • 3,529
  • 2
  • 26
  • 40