我正在开发我的 Android 应用程序,我有一个 Activity 显示项目列表,然后是另一个用于编辑特定项目的 Activity。但是现在我在从编辑项目返回时在 restartLoader() 中得到一个 NullpointerException。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
getLoaderManager().restartLoader(LOADER_ID, null, this);
}
我假设 ResultInfo 中的 who 不应该为空,但这只是一个猜测。
08-10 00:44:26.427: E/AndroidRuntime(723): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity {duttsoft.travel/duttsoft.travel.TravelHealthActivity}: java.lang.NullPointerException
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread.access$1100(ActivityThread.java:123)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.os.Handler.dispatchMessage(Handler.java:99)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.os.Looper.loop(Looper.java:137)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-10 00:44:26.427: E/AndroidRuntime(723): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 00:44:26.427: E/AndroidRuntime(723): at java.lang.reflect.Method.invoke(Method.java:511)
08-10 00:44:26.427: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-10 00:44:26.427: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-10 00:44:26.427: E/AndroidRuntime(723): at dalvik.system.NativeStart.main(Native Method)
08-10 00:44:26.427: E/AndroidRuntime(723): Caused by: java.lang.NullPointerException
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.LoaderManagerImpl.restartLoader(LoaderManager.java:651)
08-10 00:44:26.427: E/AndroidRuntime(723): at duttsoft.travel.TravelHealthActivity.onActivityResult(TravelHealthActivity.java:136)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.Activity.dispatchActivityResult(Activity.java:4649)
08-10 00:44:26.427: E/AndroidRuntime(723): at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
我正在画一个空白,为什么我会得到这个异常以及如何解决它,有什么想法吗?