我有一个活动,我强制使用键盘出现,
InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
键盘显示正确,并且在需要时也会被遮挡。问题是当我完成活动时,应用程序崩溃。如果活动从不显示键盘或在没有开始编辑文本的情况下显示它,则它已完成且没有错误,但如果您只输入一个或多个字符,应用程序将崩溃。如何解决?谢谢你。
用于完成活动的方法,
boto_back.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
finish();
}
});
@Override
public void onDestroy()
{
if (adMob != null)
{
// Destroy the AdView.
adMob.destroy();
}
super.onDestroy();
}
日志猫,
07-07 19:04:25.191: E/AndroidRuntime(8443): FATAL EXCEPTION: main
07-07 19:04:25.191: E/AndroidRuntime(8443): java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.TabBar_iOSActivity}: java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.webPush}: java.lang.NullPointerException
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2693)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2711)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.access$2100(ActivityThread.java:121)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:976)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.os.Handler.dispatchMessage(Handler.java:99)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.os.Looper.loop(Looper.java:130)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.main(ActivityThread.java:3701)
07-07 19:04:25.191: E/AndroidRuntime(8443): at java.lang.reflect.Method.invokeNative(Native Method)
07-07 19:04:25.191: E/AndroidRuntime(8443): at java.lang.reflect.Method.invoke(Method.java:507)
07-07 19:04:25.191: E/AndroidRuntime(8443): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-07 19:04:25.191: E/AndroidRuntime(8443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
07-07 19:04:25.191: E/AndroidRuntime(8443): at dalvik.system.NativeStart.main(Native Method)
07-07 19:04:25.191: E/AndroidRuntime(8443): Caused by: java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.webPush}: java.lang.NullPointerException
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2693)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2603)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.LocalActivityManager.dispatchDestroy(LocalActivityManager.java:622)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityGroup.onDestroy(ActivityGroup.java:85)
07-07 19:04:25.191: E/AndroidRuntime(8443): at com.xxxx.projecte1.TabBar_iOSActivity.onDestroy(TabBar_iOSActivity.java:417)
07-07 19:04:25.191: E/AndroidRuntime(8443): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2680)
07-07 19:04:25.191: E/AndroidRuntime(8443): ... 11 more