ActionBarCompat – App icon action (click) not working on 4.0 devices

I have this problem with the Android ActionBarCompat project: On emulators with Android 4.0 the click on the app icon doesn’t cause any onOptionsItemSelected event, whereas it works on all other OS versions.

Any input is greatly appreciated!

  • Automatic Translation tool for Android
  • is it possible backup and RESTORE a database file in android? non root devices
  • TextView selection with Spannable and LinkMovementMethod
  • Creating a drawable & zoomable image view in android
  • How to implement Video trimming on android like instagram or Whatsapp?
  • Android Restarting the Application
  • Related posts:

    Adding App Specific Entry into the Android Settings Menu
    Do efficient SQLite Inserts with Android
    Customizing Android ListView Colors?
    How to remove description from chart in MPAndroidChart?
    How to debounce a retrofit reactive request in java?
    Android: Playing an Asset Sound Using WebView
  • Create only one instance of Service (Android)
  • Multiple dex files - Conversion to Dalvik format failed - Unable to execute dex
  • SQLiteOpenHelper.getWriteableDatabase() null pointer exception on Android
  • java.lang.Object cannot be resolved in Eclipse
  • Ring shape in android
  • Eclipse stops highlighting references after a while
  • 2 Solutions collect form web for “ActionBarCompat – App icon action (click) not working on 4.0 devices”

    Are you seeing any touch feedback from the app icon? (Does it glow when you press it?)

    Since many activities do not use the action bar home button, in apps that target API 14+ running on Android 4.0 it is disabled by default. (This is so that users don’t try pressing it, see it glow, and wonder why nothing happened.) Apps that want to use this should call ActionBar#setHomeButtonEnabled(true).

    We should probably revise the ActionBarCompat sample to surface this more clearly. One simple way to get you up and running would be to modify ActionBarHelperICS.java and add the following:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mActivity.getActionBar().setHomeButtonEnabled(true);
    }
    

    In an app where you want more control over turning this on and off you would want to make further changes.

    I had this problem as well. This code did the trick for me:

    public void onCreate(Bundle savedInstanceState) {
        ...
        if (android.os.Build.VERSION.SDK_INT >= 11) {
            //noinspection ConstantConditions
            getActionBar().setHomeButtonEnabled(true);
        } else {
            getSupportActionBar().setHomeButtonEnabled(true);
        }
    }
    

    Some extra info: minSdkVersion="7" targetSdkVersion="18". This is the LAUNCHER activity of my project, so it has no parent activity. Using setDisplayHomeAsUpEnabled(true) in other activities worked just fine.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.