We've used the this in the past, but I can't guarantee its at all forward
compatable (or if it works on newer devices):
private InputMethodManager mImm;
private Context mContext;
mImm =
(InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
mImm.getInputMethodList();
And when requesting to display the keyboard:
public void showSoftInput(View v) {
mImm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
}
This is also only available as of version 3, we've wrapped it in a wrapper,
to allow for backwards compat:
public class WrapInputMethodManager {
private InputMethodManager mImm;
private Context mContext;
static {
try {
int ver = Integer.parseInt(Build.VERSION.SDK);
if (ver < 3) {
throw new Exception("Too low version");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void checkAvailable() { }
public WrapInputMethodManager(Context c) {
mContext = c;
mImm =
(InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
mImm.getInputMethodList();
}
public void showSoftInput(View v) {
mImm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
}
}
And then use it as:
try {
WrapInputMethodManager.checkAvailable();
mRunningCupcake = true;
mImm = new WrapInputMethodManager(mContext);
mImm.showSoftInput(view);
} catch (Throwable t) {
mRunningCupcake = false;
}
Good luck :)
On Sun, Dec 13, 2009 at 4:07 PM, paul zazzarino <
[email protected]> wrote:
>
> Anyone know of a good way to popup the software keypad automatically on
> entry to a new screen ?
>
> This almost works as I can generate keys in the first field on the screen,
> but it does not work with the DPAD
>
> for example this fills a field with character 0
>
>
>
> *ke* = new KeyEvent(KeyEvent.ACTION_DOWN , KeyEvent.KEYCODE_0);
>
> EditText01.dispatchKeyEvent(*ke*);
>
> *ke* = new KeyEvent( KeyEvent.ACTION_UP , KeyEvent.KEYCODE_0);
>
> EditText01.dispatchKeyEvent(*ke*);
>
> This should simulate a center DPAD click but does not
>
>
> *ke* = new KeyEvent(KeyEvent.ACTION_DOWN , KeyEvent.KEYCODE_DPAD_CENTER);
>
> EditText01.dispatchKeyEvent(*ke*);
>
> *ke* = new KeyEvent( KeyEvent.ACTION_UP , KeyEvent.KEYCODE_DPAD_CENTER);
>
> EditText01.dispatchKeyEvent(*ke*);
>
>
>
> Earlier example were done using IWindowManager but this class has been
> removed in later versions.
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<android-discuss%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/android-discuss?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Android Discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/android-discuss?hl=en.