I am trying to programatically select a spinner button from inside an
app, basically mapping DPAD actions to a focus selection.  [adding
Google TV support]

i.e. select a Spinner inside listview item if the user presses the
DPAD key:

Tried a number of things setting the
listview.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS)
attributes


Another attempt was to send motion events but motion events appear to
be considered a security issue. [arguuhh, it was so easy in
Windows.....]


Funny you can send key events, by motion events appear to be
disallowed [see src code following....]


The instrumentation APIs puts too much overhead on selecting gui
controls.


Another possibility is to directly talk to the service manager from an
App ?
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, eventTime,
MotionEvent.ACTION_DOWN, x,y, 0);
v.dispatchTouchEvent(event);


///////// src from instrumentation class ///////////


         public void sendPointerSync(MotionEvent event) {
                validateNotAppThread();
                try {
                    (IWindowManager.Stub.asInterface(ServiceManager
                            .getService("window"))).injectPointerEvent(event,
                            true);
                } catch (RemoteException e) {
                }
            }


link to instrumentation class


http://www.java2s.com/Open-Source/Android/android-core/platform-frame...



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to