I have an android alarm app that was working nice up to SDK 32. When I set the targetSdkVersion to 33 now when the alarm fires, and the app is in the background, system is locked, the Alarm sound is audible but the app cannot show on screen (screen keeps locked). The activity that should have been started with the AlarmReceiver is not even created. That activity is used to dismiss the alarm and display some other info to the user (only when the screen is locked). any one can help please? code snippets are below
AndroidManifest.xml:
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!-- <uses-permission android:name=""-->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
AlarmReciver.java:
if (isDeviceLocked(context))
{
Intent detailsIntent = new Intent(context, AlarmDetails.class);
//do some extra stuff like setting text for the intent...
//.....
//...
detailsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);
detailsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(detailsIntent); //this doesn't even call create in the activity!!!
}
else
{
//display notifications only....
}
function isDeviceLocked checks the status of the lock screen as documentation suggested (works very well).
Appreciate any help I can get. This is wasting my time so far and I have to release against SDK 33 as per Mr. Google