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?
android:protectionLevel="signature"
in manifest file and if your target API is23
then you should use run time permission. – Linguiform