我正在 Android 中创建一个应用程序,但是当我想更新一些数据时,我想重新启动我的 MainActivity。但是当我尝试重新启动我的应用程序时,它会崩溃。
我使用以下代码重新启动我的活动
case R.id.update:
admin = false;
Intent intent1 = getIntent();
finish();
startActivity(intent1);
break;
我的日志是
04-22 12:28:10.444: E/AndroidRuntime(11867): FATAL EXCEPTION: main
04-22 12:28:10.444: E/AndroidRuntime(11867): java.lang.RuntimeException: Unable to start activity ComponentInfo{package_____________/package________.LauncherGridActivity}: java.lang.NullPointerException
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.os.Handler.dispatchMessage(Handler.java:99)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.os.Looper.loop(Looper.java:137)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-22 12:28:10.444: E/AndroidRuntime(11867): at java.lang.reflect.Method.invokeNative(Native Method)
04-22 12:28:10.444: E/AndroidRuntime(11867): at java.lang.reflect.Method.invoke(Method.java:511)
04-22 12:28:10.444: E/AndroidRuntime(11867): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-22 12:28:10.444: E/AndroidRuntime(11867): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-22 12:28:10.444: E/AndroidRuntime(11867): at dalvik.system.NativeStart.main(Native Method)
04-22 12:28:10.444: E/AndroidRuntime(11867): Caused by: java.lang.NullPointerException
04-22 12:28:10.444: E/AndroidRuntime(11867): at com.___________.ApplicationManager.loadFilteredNames(ApplicationManager.java:228)
04-22 12:28:10.444: E/AndroidRuntime(11867): at com______.ApplicationManager.loadApplications(ApplicationManager.java:65)
04-22 12:28:10.444: E/AndroidRuntime(11867): at co___.LauncherGridActivity.onCreate(LauncherGridActivity.java:142)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.Activity.performCreate(Activity.java:4465)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-22 12:28:10.444: E/AndroidRuntime(11867): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-22 12:28:10.444: E/AndroidRuntime(11867): ... 11 m