How to interact with ActionBar from NativeActivity with Java-side window content (Xperia Play)?

814 Views Asked by At

For the Xperia Play prior to ICS, the only way to get input from the touchpad is through a NativeActivity (not a plain old Activity). Unfortunately, all drawing in a NativeActivity, as the name suggests, is done on the native-side, not Java-side. In order to get input on the native-side with graphics on the Java-side, the following must be added to the NativeActivity's onCreate method:

    getWindow().takeSurface( null );
    getWindow().setContentView( R.layout.main );

And set up a couple methods through JNI for receiving the touchpad and touchscreen input from the native-side. You can then happily draw through Android's Java API, while still getting the touchpad input. This works quite well for Xperia Play's running pre-ICS. Even adding menus via onCreateOptionsMenu doesn't cause any problem.

The problem comes when the Xperia Play is running ICS. The menu has moved to the Action Bar. Unfortunately, it isn't possible to interact with the action bar (pressing the 3 dots is ignored, and it acts like I'm pressing the surface behind the action bar.)

In case it makes any difference, I am creating the action bar menu options through onCreateOptionsMenu. I am using Window.FEATURE_ACTION_BAR_OVERLAY, and making the actionbar visible like so when the user presses the "back" button (mSingleton is the NativeActivity instance):

mSingleton.runOnUiThread(
    new Runnable()
    {
        public void run()
        {
            if( mSingleton.getActionBar().isShowing() )
                mSingleton.getActionBar().hide();
            else
                mSingleton.getActionBar().show();
        }
    } );

This makes the action bar visible, but as I mentioned, I can't interact with it. Is there a way to force the action bar to have focus or something? The fact that normal menus work fine on pre-ICS versions makes me think it should be possible to interact with the action bar too, since it is just a menu of a different type.

0

There are 0 best solutions below