As an update to the the code I showed above, I'm currently working
with the following code. This seems to be behaving the way I would
want it to.
On a phone with a physical keyboard:
- if keyboard is not hidden don't bring up the soft keyboard.
- if the keyboard is hidden, need to do the SHOW_FORCED option which
is handled in the ResultReceiver class.
- depending on how you exit, it may leave the keyboard up - not
desirable, so I might try to address this.
On a phone without a physical keyboard:
- SHOW_IMPLICIT seems to work nicely and the keyboard doesn't stay up
when you exit the application.
View.OnLongClickListener mLongClickListener = new
View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
softKeyboardResults rr = new softKeyboardResults();
Configuration config =
MyView.this.getResources().getConfiguration
();
if (config.hardKeyboardHidden ==
Configuration.HARDKEYBOARDHIDDEN_YES) {
InputMethodManager imm = (InputMethodManager)
MyView.this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(MyView.this,
InputMethodManager.SHOW_IMPLICIT,
rr);
}
return false;
}
};
class softKeyboardResults extends ResultReceiver {
public softKeyboardResults() {
super(getHandler());
}
@Override
protected void onReceiveResult(int resultCode, Bundle
resultData) {
super.onReceiveResult(resultCode, resultData);
switch (resultCode) {
case InputMethodManager.RESULT_HIDDEN:
case InputMethodManager.RESULT_SHOWN:
case InputMethodManager.RESULT_UNCHANGED_SHOWN:
break;
case InputMethodManager.RESULT_UNCHANGED_HIDDEN:
InputMethodManager imm = (InputMethodManager)
MyView.this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(MyView.this,
InputMethodManager.SHOW_FORCED);
break;
default:
break;
}
}
}
Still testing....
Best Regards,
Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---