So here is what I am trying to understand.
I have a service like this
public MyService extends Service {
public List<MyListener> listenersList = new ArrayList<>();
public void addListeners(MyListeners mylistener) {
listenersList.add(myListener);
}
public void eventAOccured(){
for ( MyListner mylistener : listeners ) {
mylistener.eventAOccured();
}
}
public void eventBOccured(){
for ( MyListner mylistener : listeners ) {
mylistener.eventBOccured();
}
}
}
And here is my MyListener Interface which activities
public Interface MyListener {
public eventAOccured();
public eventBOccured();
}
Now we have three activites
public Activity1 extends AppCompatActivity implements MyListener{
public static int myVariable = 1;
//starts service. For sake of brevity I am skipping this part.
MyService.add(this);
//on click of a button
startActivity( new Intent (Activity1.this, Activity2.class);
//Now I know this will put Activity1 in paused state
@Override
public void eventAOccured() {
//Call activity 3
}
@Override
public void eventBOccured() {
myVariable = 3;
}
}
This is the second activity which is called by clicking a button in activity 1. After Activity2 is launched, lets say eventB occurs. Now If I access myVariable from Activity1, will it be 1 or 3.
After some time let us say, eventA has occured. Now will Activity3 will be launched?
I know an activity being paused means it is no longer visible to the user, but will the communication with service continue?