崩溃startActivityForResult(意图,1);

时间:2012-06-28 13:22:56

标签: android android-activity

我的Android应用程序有问题,我有一个手册页,我改变了我的业务

startActivityForResult (intent, CODE_DE_MON_ACTIVITE).

它有效,但是当我替换此页面时,因为第二个活动使用相同的代码但没有任何效果。应用程序崩溃。 知道我在Manifest中有所有活动。

日志:

06-28 13:09:47.765: D/AndroidRuntime(254): Shutting down VM
06-28 13:09:47.765: W/dalvikvm(254): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
06-28 13:09:47.765: E/AndroidRuntime(254): Uncaught handler: thread main exiting due to uncaught exception
06-28 13:09:47.775: E/AndroidRuntime(254): java.lang.RuntimeException: Unable to start activity ComponentInfo{referencehit.android/referencehit.android.AddTournamentActivity}: java.lang.NullPointerException
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.os.Looper.loop(Looper.java:123)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread.main(ActivityThread.java:4363)
06-28 13:09:47.775: E/AndroidRuntime(254):  at java.lang.reflect.Method.invokeNative(Native Method)
06-28 13:09:47.775: E/AndroidRuntime(254):  at java.lang.reflect.Method.invoke(Method.java:521)
06-28 13:09:47.775: E/AndroidRuntime(254):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-28 13:09:47.775: E/AndroidRuntime(254):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-28 13:09:47.775: E/AndroidRuntime(254):  at dalvik.system.NativeStart.main(Native Method)
06-28 13:09:47.775: E/AndroidRuntime(254): Caused by: java.lang.NullPointerException
06-28 13:09:47.775: E/AndroidRuntime(254):  at referencehit.android.AddTournamentActivity.onCreate(AddTournamentActivity.java:38)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-28 13:09:47.775: E/AndroidRuntime(254):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
06-28 13:09:47.775: E/AndroidRuntime(254):  ... 11 more
06-28 13:09:47.788: I/dalvikvm(254): threadid=7: reacting to signal 3
06-28 1
3:09:47.788: E/dalvikvm(254): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

您对我的问题有所了解吗?

2 个答案:

答案 0 :(得分:1)

您是否实际为Intent分配了一个值?当您拨打Intent intent;时,简单地编码NullPointerException就会抛出startActivity(intent);。或者,您是否已将第二个活动添加到清单文件中? Android不会启动不在其清单中的活动。

答案 1 :(得分:1)

将以下权限添加到AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

如果您忘记添加它,请添加它。