Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start Activity from WorkManager API Level 29+

We can't start activity from Work Manager according to the new Restrictions If App doesn't meet the requirements. All i want is to start activity from Work Manager even application is killed or no longer visible after some specific time. I do not want to run the App in foreground. Is there anyway, I can achieve this?

Any help would be appreciated.

like image 908
Saad Khan Avatar asked Oct 25 '25 11:10

Saad Khan


2 Answers

If you have in house App or for testing, You can use this approach.

Add this permission in Menifest.

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

Also go to the App info settings

Setting -> Advanced -> Display over other apps

Allow this permission for this app. Now run the app, This will be able to start the activity from background.

But, I recommend to show notification and open the screen on tap notification.

like image 92
Saad Khan Avatar answered Oct 27 '25 01:10

Saad Khan


You shouldn't start activities from background since it interrupts user's work.

If you want to open your app from work manager, you'll have to use notifications instead and set the notification tap action to open your specific activity using pending intents.
Here is a guide on how to create a notification in android.

Additionally, if your app needs to do something urgently, you can create a high priority notification, details here

like image 38
Shivam Pokhriyal Avatar answered Oct 27 '25 00:10

Shivam Pokhriyal