My Activity is extending ActionBarActivity and we are setting a back navigation button in onCreate() :
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(getSupportActionBar()!=null)
{
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
and for back press, finishing this activity is on given overridden method but it's not moving to previous activity
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Your id is wrong. so please change your id 'R.id.home' to 'android.R.id.home:'.
switch (item.getItemId())
{
case android.R.id.home:
finish();
return true;
}
Try this.