问题描述
- andorid app进入一个特定的画面按home后台后,切换系统语言,app直接挂掉了,空指针
-
报错的原因是getFragmentManager().beginTransaction();为空指针,这是为什么呢?01-01 08:22:13.900: D/patnav_app_app_receiver(4055): onReceive:android.intent.action.LOCALE_CHANGED
01-01 08:22:13.960: D/AndroidRuntime(4055): Shutting down VM
01-01 08:22:13.960: W/dalvikvm(4055): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-01 08:22:14.220: D/dalvikvm(4055): GC_CONCURRENT freed 1296K, 36% free 2825K/4359K, external 8824K/10843K, paused 3ms+2ms
01-01 08:22:14.230: E/AndroidRuntime(4055): FATAL EXCEPTION: main
01-01 08:22:14.230: E/AndroidRuntime(4055): java.lang.RuntimeException: Unable to destroy activity {com.pateonavi.naviapp/com.pateonavi.naviapp.activity.MainMapActivity}: java.lang.NullPointerException
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2672)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2690)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread.access$2100(ActivityThread.java:117)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:964)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.os.Looper.loop(Looper.java:130)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-01 08:22:14.230: E/AndroidRuntime(4055): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 08:22:14.230: E/AndroidRuntime(4055): at java.lang.reflect.Method.invoke(Method.java:507)
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
01-01 08:22:14.230: E/AndroidRuntime(4055): at dalvik.system.NativeStart.main(Native Method)
01-01 08:22:14.230: E/AndroidRuntime(4055): Caused by: java.lang.NullPointerException
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.pateonavi.naviapp.mode.RoutePlanMode$1.onModeClosed(RoutePlanMode.java:88)
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.pateonavi.navilib_as21.mode.BaseMode.onDestroy(BaseMode.java:79)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1031)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1065)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1877)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:316)
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.pateonavi.navilib_as21.maps.MapActivity.onDestroy(MapActivity.java:39)
01-01 08:22:14.230: E/AndroidRuntime(4055): at com.pateonavi.naviapp.activity.MainMapActivity.onDestroy(MainMapActivity.java:1264)
01-01 08:22:14.230: E/AndroidRuntime(4055): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2659)
01-01 08:22:14.230: E/AndroidRuntime(4055): ... 11 more
01-01 08:22:14.420: I/Process(4055): Sending signal. PID: 4055 SIG: 9
解决方案
ondestroy里面的代码呢
解决方案二:
你应该有注册广播,这个action应该是没设定,然后在调用
destroy里面的方法时,就出现了空值