Search code examples
androidkotlinservicepolicyandroid-workmanager

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.


Solution

  • 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.