Even With setHomeButtonEnabled(true) App Icon not Clickable in Android 14
Asked Answered
K

2

5

my Code: (Updated) I've Added my onCreateOptionsMenu And onOptionsItemSelected Method here :

  ActionBar actionBar = getActionBar();
  actionBar.setHomeButtonEnabled(true);
  actionBar.setDisplayHomeAsUpEnabled(true);
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.login, menu);
    return true;
    }
   @Override
   public boolean onOptionsItemSelected(MenuItem item) {
   // Handle item selection
   switch (item.getItemId()) {
       case R.id.action_createInvoice:
           startActivity(new Intent("com.domain.Activity1"));
           return true;

       default:
           return super.onOptionsItemSelected(item);
       }
   }

my Manifest File:

    <uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />

    <activity android:label="@string/activity" android:name=".Activity"
        android:parentActivityName="com.some.activity">
         <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.some.activity" />
        <intent-filter>
            <action android:name="com.this.activity" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

With this settings, App Icon not Clickable in Android 14 Emulator

Ku answered 7/8, 2013 at 11:35 Comment(4)
Did you override onOptionsItemSelected?Factitious
Yes Adrian i did, but it's not about these method i thinkKu
where did you put actionBar.setDisplayHomeAsUpEnabled(true); ?Moreau
in onCreate method=> protected void onCreate(Bundle paramBundle)Ku
M
11

override onOptionsItemSelected() :

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // do your stuff here, eg: finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

For a list of Android's ids :http://developer.android.com/reference/android/R.id.html#home

Moreau answered 7/8, 2013 at 11:38 Comment(6)
Yes i did: @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.action_createInvoice:Ku
Do you have a case for android.R.id.home?Factitious
Exactly home? no but my ChildActivity yesKu
Thanks Adrian, i finally release i missed (case android.R.id.home) this is Special to ParentActivity i put it to my codes and it works fine.Ku
@Tom91136 Could you please explain where is this R.id.home come from?I too face similar problem. Application home button clickable using actionBar.setHomeButtonEnabled(true) method. But I could not find out a way to detect its click in code. #22755233Termination
oops find out the issue. It should be android.R.id.home. Thanks.Termination
P
0

try this it worked for me

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();
    if (id==android.R.id.home)
    {
        NavUtils.navigateUpFromSameTask(this);
    }
    return super.onOptionsItemSelected(item);
}
Parenthood answered 1/2, 2016 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.