0

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.

TZHX
  • 5,291
  • 15
  • 47
  • 56
paulscode
  • 1,049
  • 1
  • 12
  • 29
  • What version of ICS are you running on Xperia Play?Also I need to know if it's a mod or a beta release from Sony Mobile. – Anup Jun 05 '12 at 22:30
  • I do not personally own an Xperia Play, but since this problem relates to the touch-screen, it isn't necessary. Also, NativeActivity isn't used only for Xperia Play. That said, I can post on XDA Developers to have folks with various versions of ICS to see if that makes any difference. Anyway, I'm developing the code on a Galaxy Nexus, with unmodified stock Android 4.0.4 (kernel 3.0.8-gda6252b). The behavior affects at least this device and version of ICS. – paulscode Jun 07 '12 at 20:30

0 Answers0