How to Redirect from Android MainActivity to an already running Foreground service with full screen intent

29 Views Asked by At

I am developing an Alarm application, when the alarm fires up it launches a full screen intent with foreground service.

If the user goes to home, then tries to open the app I want him to get redirected to the foreground service full screen intent.

The application is multi-module, The foreground service exists in scheduler module and I am trying to mutate the Main Activity in the UI.

I tried checking if the service is already running and then launch a startActivity with an intent to the foreground service using the main activity context. However, It throws the following exception

android.content.ActivityNotFoundException: Unable to find explicit activity class

1

There are 1 best solutions below

0
CommonsWare On

then launch a startActivity with an intent to the foreground service

Replace that with a startActivity() call to the activity that you want to show. The Intent you pass to startActivity() needs to point to the activity. That is because you are trying to start an activity. The fact that this activity also happens to be used by a full-screen Intent for a foreground service Notification does not matter.