in my app i am using menu back button to go back to previous activity. one of my activity is getting intent from its previous activity and after doing http call it is sending intent to next activity so flow is kind of A1--intent--> A2 -- intent--> A3 . the problem is when i come back to activity A2 from A3 it crashes. the reason would be empty intent i believe. so i added below code in Activities A3 and A2
activity A3
public boolean onOptionsItemSelected(MenuItem menuItem) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (menuItem.getItemId()) {
case android.R.id.home:
Intent homeIntent = new Intent(context, AllClasses.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
homeIntent.putExtras(b); // bundle b has the required data for A2
startActivity(homeIntent);
}
return super.onOptionsItemSelected(menuItem);
}
activity A2
protected void onReStart(){
// retreiving data from intent
Bundle b = new Bundle();
b = getIntent().getExtras();
String imessage_string = b.getString("imessage");
Log.d("onrestart",imessage_string);
}
Problem :- now the problem is that now if i press back button on menu bar of A3 first i see the message "unfortulately project has stopped " and then after pressing "OK" A2 starts like i have moved from A1 to A2 and makes call to asyncTask. if i comment "homeIntent.putExtras(b);" in A3 then i recevie the error message twice and jump directly to A1. i am sure on returning to A2 my onRestart() method is not being called as i havn't made any call to asyncTask in that. Does anyone gets any idea what i should do here ? Thanks for you help in advance.... :)