Skip to content Skip to sidebar Skip to footer

Clicking App Icon Doesn't Trigger Onoptionsitemselected()

I'm currently working on an Android app. I would like to use the app icon in the action bar to navigate to the 'home' activity. I read on this page that all that needs to be done i

Solution 1:

For packages targetting API level 14 onwards, you need to enable the home button by calling setHomeButtonEnabled()

In your onCreate, add the following:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    getActionBar().setHomeButtonEnabled(true);
}

Solution 2:

If you use Android new support-actionbar (AppCompat) you need to make both calls.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    getActionBar().setHomeButtonEnabled(true);
}
getSupportActionBar().setHomeButtonEnabled(true);

Solution 3:

i dont know if we have the same problem.

but, i was on that problem and now solved..

do you add

case android.R.id.home:
    Intent intent = newIntent(this, HomeActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    returntrue;

in HomeActivity ? this is false..

you should put that code on your secondActivity.. because your home button on secondActivity, not HomeActivity

case android.R.id.home:
     NavUtils.navigateUpFromSameTask(this);
     true;

hope this helps you

Post a Comment for "Clicking App Icon Doesn't Trigger Onoptionsitemselected()"