Problem: I have to check if my application is working or not (when the service is already running in the background). Based on this, I believe that I am either starting a specific activity or application.
The thing that I tried or came up with, but failed I tried to check the current current process and based on it tried to decide whether the application was working or not. The reason for the failure: to get the application launch status, as always, since I already had a service running in the background.
A possible solution, but not sure if this is possible in android 1. If we can start the service under a different name (package name) 2. Set some logical value to true and false to start and close the application, respectively. But is this a good approach?
EDIT ::
Sorry if I was not very descriptive before. I am trying to explain to you exactly what I am trying to achieve.
Whenever the user clicks on the notification. I have to execute either of two options after checking the launch of my application (excluding services, since they always work in the background). 1. If my application is already running, just start the required activity. 2. If the application is not running, I have to start it and then open the required activity.
For example, I receive a notification of receipt of a message. If my application is running, I must show the Inbox, otherwise I need to start the application and open the Inbox.
source share