I ran this on the emulator with no luck but after tinkering around with it this 
displays the keypad each time.

InputMethodManager mImm;


mImm = (InputMethodManager)this.getSystemService(Context.INPUT_METHOD_SERVICE);

mImm.getInputMethodList();

//mImm.showSoftInput(EditText01, InputMethodManager.SHOW_FORCED);


mImm.toggleSoftInput(mImm.SHOW_FORCED, 0);



[seems like the keystoke method could work as well, if one could set the focus 
on the DPAD before dispatching the keys.]

dpadobject =  findViewById(R.id.DPAD);    // ???  ??? ??? 

ke = new KeyEvent(KeyEvent.ACTION_DOWN , KeyEvent.KEYCODE_0);

dpadobject.dispatchKeyEvent(ke);

ke = new KeyEvent( KeyEvent.ACTION_UP , KeyEvent.KEYCODE_0);

dpadobject.dispatchKeyEvent(ke);

anyone know if you can query the view of the DPAD to set the focus ????





  ----- Original Message ----- 
  From: Dan Sherman 
  To: [email protected] 
  Sent: Sunday, December 13, 2009 4:26 PM
  Subject: Re: [android-discuss] Popup software keypad & KeyEvents


  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].
    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.

--

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.


Reply via email to