Here i setup this on oncreate method of second avticity
super.onCreate(savedInstanceState);
// Actionbar
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.new_message);
And this is onOptionsItemSelected
public boolean onOptionsItemSelected(MenuItem item) {
// 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.
int id = item.getItemId();
if (id == R.id.action_save) {
Intent newMessage = new Intent(getApplicationContext(),NewMessage.class);
startActivity(newMessage);
}
if(id == R.id.home){
Toast.makeText(getApplicationContext(), "Home button click", 2000).show();
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
}
/* return super.onOptionsItemSelected(item);*/
return true;
}
Is there anything i need to change somewhere else like Manifest or some othere there is no code for back activity on MainActivity