1

I am making an alarm application. When the alarm goes off it calls the broadcast receiver and from there i am getting wake lock to wake up the screen and to bring the app up, and then using an intent to get to an activity. This use to work on my pixel 2 with android 9 but when i upgraded to android 10 the screen comes on but the app doesnt start and it doesnt navigate to the intent. I have a samsung galaxy s6 with android 6 and its working fine with.

I debugged the code and its calling the broadcast reciever and running the code fine.

Is there something i need to do for android 10?

in my broadcast reciever

alarmIntent = new Intent(context, showActivity.class);
alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(alarmIntent);

here is my wake lock

public static void acquire(Context ctx){
    if(wakeLock!=null)wakeLock.release();



    KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);

    KeyguardManager.KeyguardLock keyguardLock =  keyguardManager.newKeyguardLock("TAG");
    keyguardLock.disableKeyguard();

    PowerManager pm=(PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP ), "tag:TAG");


    wakeLock.acquire(10000);

in my manifest

 <uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />


<receiver
        android:name=".pac.AlarmReceiver"
        android:enabled="true"
        android:exported="false">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>

and in the activity that suppose to fire showActivity.class

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
                    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_FULLSCREEN |
                    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

my compiled SDK and targeted sdk - it wont let me select api 29

compileSdkVersion 28
targetSdkVersion 28

Is there anything i need to do for android 10 and wake lock getting my app to wake up and intent to an activity? This works fine in android 9 and lower.

steller
  • 245
  • 3
  • 14
  • Your answer doesnt help me. im trying to start an activity not a notification and i am not using pendingintent. Im confused on how to do this – steller Sep 28 '19 at 23:32

0 Answers0