I have a service and its behavior must change when topmost Activity changes. Say, Activity A is active and then service starts some kind of processing. This processing must
Create a baseActivity and extends all other Activities from baseActivity, in onResume save Current Activity in a public static Filed in a Global class (in my case extends Application)
public class baseActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
Global.Activity = this;
}
}
Other Activities
public class mainActivity extends baseActivity {
// You Can Use Global.Activity Everywhere ! , Even in a Object Extended Class
}