活动附加 - 返回

时间:2014-02-01 23:43:04

标签: android android-activity

我遇到问题,使用此代码启动新活动(活动A):

Intent intent = new Intent(MainActivity.this, SezioniListActivity.class);
intent.putExtra("mat",mat);
startActivity(intent);

然后我做了我需要做的mat对象,然后我开始一个新的活动(活动B)

Intent intent = new Intent(SezioniListActivity.this, TestiListActivity.class);
intent.putExtra("sez",sez);
startActivity(intent);

问题是,当我从这个活动回来我的应用程序崩溃时,我认为问题是,当我去bak我的旧对象“mat”与先例obj不一样时,我认为它是null。 ..我可以解决这个问题吗?

编辑3:

Main http://pastebin.com/2ad1nwPy
Sezioni http://pastebin.com/DqnVzG4a
Test http://pastebin.com/3hh2NmtT

编辑2:

我以这种方式获得价值: (活动A) materia =(Materia)getIntent()。getExtras()。getSerializable(“materia”);

(活动B) sezione =(Sezione)getIntent()。getExtras()。getSerializable(“sezione”);

编辑1:

02-02 00:46:36.109: D/Materia:(28022): viva
02-02 00:46:36.113: D/AndroidRuntime(28022): Shutting down VM
02-02 00:46:36.113: W/dalvikvm(28022): threadid=1: thread exiting with uncaught exception (group=0x41631ba8)
02-02 00:46:36.140: E/AndroidRuntime(28022): FATAL EXCEPTION: main
02-02 00:46:36.140: E/AndroidRuntime(28022): Process: com.example.testfun, PID: 28022
02-02 00:46:36.140: E/AndroidRuntime(28022): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testfun/com.example.testfun.SezioniListActivity}: java.lang.NullPointerException
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.os.Handler.dispatchMessage(Handler.java:102)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.os.Looper.loop(Looper.java:136)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread.main(ActivityThread.java:5017)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at java.lang.reflect.Method.invokeNative(Native Method)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at java.lang.reflect.Method.invoke(Method.java:515)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at dalvik.system.NativeStart.main(Native Method)
02-02 00:46:36.140: E/AndroidRuntime(28022): Caused by: java.lang.NullPointerException
02-02 00:46:36.140: E/AndroidRuntime(28022):    at com.example.testfun.SezioniListActivity.onCreate(SezioniListActivity.java:30)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.Activity.performCreate(Activity.java:5231)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-02 00:46:36.140: E/AndroidRuntime(28022):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-02 00:46:36.140: E/AndroidRuntime(28022):    ... 11 more
02-02 00:46:52.718: I/Process(28022): Sending signal. PID: 28022 SIG: 9
02-02 00:46:53.273: D/OpenGLRenderer(28178): Enabling debug mode 0

0 个答案:

没有答案