How to send KeyEvents through an input method service to a Dialog, or a Spinner menu?

by shutdown11 » Wed, 14 Apr 2010 03:35:09 GMT


Sponsored Links
 I'm trying to implement an input method service that receives intents
sent by a remote client, and in response to those sends an appropriate
KeyEvent.

I'm using in the input method service this method

private void keyDownUp(int keyEventCode) {
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
    }
to send KeyEvents as in the Simple Sofykeyboard Sample, and it works
in the home, in Activities... but it doesn't works when a Dialog or
the menu of a Spinner is in foreground.

The events is sent to the parent activity behind the Dialog.

Is there any way to send keys and control the device like using the
hardware keys from an input method?

--



Other Threads

1. How to successfully embed a ListView in a Dialog?

Hi all,

I have been trying this thing for  about 16 hours now ...

my code:

public MyDialog (Context context)           //Dialog constructor
{

                super(context);
                this.setTitle(R.string.track_choose);
                //this.setContentView(R.layout.trackmode_);

                                participants = new String [2];
                                participants[1] = "cucu";
                                participants[2] =
"ffffffffffffffffffffffffgggggggggggggggggggggggggggggggggggg";

                ArrayList<String> arr = new ArrayList<String> (2);
                arr.add("cucu");
                arr.add("mirabelafdfjsfgyugfyubjcwfnewhf7387ft38fg");
                //listAdapter = new ArrayAdapter<String>(context,
android.R.layout.simple_list_item_1, participants);
                        listAdapter = new
ArrayAdapter<String>(getContext(), R.layout.trackmode, participants);
                //listAdapter = new ArrayAdapter<String>(context,
R.layout.trackmode, arr);

                //ListView participantList = (ListView)
this.findViewById(R.id.listParticipants);
                                participantList = new ListView
(getContext());
                LinearLayout.LayoutParams params = new 
LinearLayout.LayoutParams (1,
0x77);
                //participantList.setLayoutParams(params);

                                participantList.setAdapter(listAdapter);
                participantList.setOnItemSelectedListener(this);

                                //this.setContentView
(participantList);

                this.addContentView (participantList, params);
                participantList.setEnabled(true);
                //participantList.setItemsCanFocus(true);
                participantList.setVisibility(View.VISIBLE);
        }

I have also tried to move this / part of this code in places such as
onPreparePanel(int featureId, View view, Menu menu)        and
onCreatePanelView(featureId) overridables with no success. Comments
were left there intentionally just to point out what I have already
tried.



R.layout.trackmode's XML is like this (and it makes no difference if I
use my own layout or android.R.layout.simple_list_item_1 resource):

<?xml version="1.0" encoding="UTF-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
                  id="textview" android:textStyle="bold" 
android:singleLine="false"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content" />


The result I am able to get right now is a neat looking transparent
dialog, with a title and a ListView object in it. However, the
ListView object only shws a veeeery thin orange vertical line on the
left side. And one can  actually see how that thin line shifts colours
as I press the arrowkeys to select Items in the ListView. Only thing
is that there are not 2 items as I intented to be, but some 5-6 items.
After the 5th or 6th, if  pressed 'down arrow' again, a
nullpointerexception is thrown.

heeeeeeeeeeeeeelp
thank you,
kellogs
--~--~---------~--~----~------------~-------~--~----~

2. EARN DOLLARS AT HOME BASED BUSINESS

Join the EyeEarn Network, and get paid to drive your car, wear T-
shirts, and more! Earn money effortlessly while you go about your day!
It fun, easy, and no experience is necessary!
http://www.ezinfocenter.com/10122618/CB


--~--~---------~--~----~------------~-------~--~----~

3. Hey!

4. Free Dating Tips!!!

5. Free Phone Call Worldwide

6. Liver Cancer Concerns?

7. Paris hilton Video clips !!!