Android:检测何时启用软键盘

Android: Detect when soft keyboard gets enabled

我已经启动了 ACTION_INPUT_METHOD_SETTING 意图,让用户可以激活 softInput(键盘)。当用户激活我想要的软件 input/keyboard.

时,我想关闭设置 activity(我开始的意图)

没有直接的方法来确定它 - 请参阅 http://groups.google.com/group/android-platform/browse_thread/thread/1728f26f2334c060/5e4910f0d9eb898a where Dianne Hackborn from the Android team has replied. However, you can detect it indirectly by checking if the window size changed in #onMeasure. See Android: Is software keyboard shown?

试试这个

   InputMethodManager imm  = (InputMethodManager)getActivity().getApplicationContext().getSystemService(    Context.INPUT_METHOD_SERVICE);
   Log.e(TAG, "Result :"+imm.isActive());    

我在这个 post from Sujay 上找到了答案:

您可以从后台关闭所有活动,当重新打开应用程序时它从第一个开始activity

this.finish();
Intent intent = new Intent(getApplicationContext(), CloseApp.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

您可以从后台关闭所有活动,当重新打开应用程序时它从暂停的地方开始activity[您关闭的地方]activity

this.finish();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);