My Android application consists of many activities, each of which represent a menu:
- Activity A (the main Activity & first level menu)
- Activity B (second level menu)
- Activity C (third and last menu)
I am monitoring the user’s action in a service. When an event (detected by service) occurs, I want to close all of Activities and restart Activity A. The code I wrote below only works in an Activity, not a Service:
Intent myIntent = new Intent();
myIntent.setClassName("main.activity", "ActivityA");
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(myIntent);
How can I do this in a Service?
What about this: