I have a MainActivity that calls a service. The service's onStart method loops until a specific variable is reached. When the variable is reached, I want the service to set off an alert to the user and bring the MainActivity to the screen so that the user can decide if they want to run the service again. Because it is a service, the MainActivity may already be in the foreground, or it may not have an instance of the activity at all. Either way, it should resume the first instance of MainActivity. I know I would have to use something such as an intent and FLAG_ACTIVITY_REORDER_TO_FRONT. I just do not know how I can implement the intent so that the MainActivity is brought to the foreground even if the user is in another app or has the app closed.
Update: The following link also helped with my problem as well. Thank you guys.
Example: Communication between Activity and Service using Messaging