0

Put the setAlarmClock of the Android11 (API30) target resource on standby in the Android Emulator of Android12 (API31). Close the app. Upgrade to Android12 (API31) target resource.

java.lang.RuntimeException: Unable to start receiver com.xxx.xxx.AlarmReceiver: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.xxx.xxx/.AlarmService

The above error occurs.

It operates normally when the above conditions are not met.

Below is the source.

am.setAlarmClock(new AlarmManager.AlarmClockInfo(alarmRun, showIntent1), pendingIntent2);

Receiver

context.startForegroundService(new Intent(context, AlarmService.class));

Is it a bug in the Android Emulator?

Will the situation be the same on the actual machine?

I can't test because I don't own the actual Android 12.

jun74
  • 11
  • 2
  • check https://stackoverflow.com/questions/70044393/fatal-android-12-exception-startforegroundservice-not-allowed-due-to-mallows – bongo Jun 17 '22 at 14:25
  • Your app invokes an exact alarm to complete an action that the user requests. It works fine except in the state of the question. – jun74 Jun 17 '22 at 14:33

0 Answers0