I use ActionbarSherlock and would like to enable the home button ...
Therefore I call setHomeButtonEnabled(true)
in my base activity.
public class BaseFragmentActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Theme_Sherlock);
super.onCreate(savedInstanceState);
getSupportActionBar().setHomeButtonEnabled(true); // Here
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
Intent intent = new Intent(this, HomeActivity.class);
// startActivity(intent);
// startActivityIfNeeded(intent, 0);
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}
}
When I use startActivity(intent)
or startActivityIfNeeded(intent, 0)
the HomeActivity
is recreated everytime (the activity renders a map and recreating it is annoying).
- I do not want to call
finish()
since it just takes me back one step in the app hierarchy. Instead I always want to return to theHomeActivity
. - Further it would be nice if the behavior could be configured in
AndroidManifest.xml
as it is described for the ActionBar and setDisplayHomeAsUpEnabled(). - It might also be common sense to clear the backstack when I return to the
HomeActivity
. What is your opinion on that?