Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Jellybean onCreateOptionsMenu is not called on Nexus 7

Tags:

android

I have a TabActivity with four tabs. When I set android:targetSdkVersion="15" the onCreateOptionsMenu method is not called on any of the tab activities when testing on a Nexus 7.

It works correctly with android:targetSdkVersion="10".

With android:targetSdkVersion="15" it works correctly when the activities are not in a TabActivity and when tested on a phone (Evo).

Here is the code for onCreateOptionsMenu.

public boolean onCreateOptionsMenu(Menu menu) {
    Log.i("Test","Base In create option menu");
    if( menuId != null ) {
        new MenuInflater(this).inflate(menuId,menu);
    }
    return super.onCreateOptionsMenu(menu);
}
like image 435
user1818726 Avatar asked Nov 12 '22 17:11

user1818726


1 Answers

Sorry but this is an easy one. According to Google:

http://developer.android.com/guide/topics/ui/menus.html

So, if you set the target SDK lower, you can show the deprecated options bar. For the newer SDKs you need to use an action bar or some other form of navigation. Basically Google decided that not all devices would have a "menu" button.

like image 163
JavaCoderEx Avatar answered Nov 15 '22 07:11

JavaCoderEx