Assume i have four classes.Each class is having a button to do screen switching from one page to another page,well its working fine.But now im trying to close all the activi
I would insist to create an BaseActivity with a BroadCastReceiver that will notify when you want to finish all the Activities and extend all the Activity classes with this BaseActivity,
public static final String ACTION_FINISH = "ACTION_FINISH";
public class BaseActivity extends Activity {
public void onCreate(Bundle bundle, int resourceId) {
super.onCreate(bundle);
registerReceiver(finishActivitiesReceiver,
new IntentFilter(ACTION_FINISH));
}
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(finishActivitiesReceiver);
}
BroadcastReceiver finishActivitiesReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
finish();
}
};
}
Then you can just send BroadCast when you want to close all Activities using
sendBroadcast(new Intent(BaseActivity.ACTION_FINISH));