2012-08-10 141 views
-4

我做了一個簡單的android應用程序,從一個活動移動到另一個活動,長度爲5個編輯文本輸入。但我得到了例外。我附加了兩個java文件(MainActicity和Another),mainfest文件和logcat輸出。有人請幫助我。 在此先感謝。在android中獲取運行時異常

下載鏈接:: http://www.4shared.com/folder/gyDYjAYC/AndroidApp.html

logcat的是:

08-10 16:15:47.289: D/AndroidRuntime(4043): Shutting down VM 
08-10 16:15:47.296: W/dalvikvm(4043): threadid=1: thread exiting with uncaught exception (group=0x40018578) 
08-10 16:15:47.296: E/AndroidRuntime(4043): FATAL EXCEPTION: main 
08-10 16:15:47.296: E/AndroidRuntime(4043): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.practice/com.example.practice.Another}: java.lang.NullPointerException 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.os.Looper.loop(Looper.java:130) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread.main(ActivityThread.java:3687) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at java.lang.reflect.Method.invoke(Method.java:507) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at dalvik.system.NativeStart.main(Native Method) 
08-10 16:15:47.296: E/AndroidRuntime(4043): Caused by: java.lang.NullPointerException 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at com.example.practice.Another.onCreate(Another.java:18) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
08-10 16:15:47.296: E/AndroidRuntime(4043):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 
08-10 16:15:47.296: E/AndroidRuntime(4043): 
... 11 more 
+0

請將您的代碼添加到問題中,這會讓人們更容易閱讀它。 – Ridcully 2012-08-10 11:24:14

+0

如果你已經描述了你的調試步驟到目前爲止,並且確切地說你的問題是什麼,那麼這個問題會更加有趣 – ekholm 2012-08-10 11:26:03

回答

1

在你Another類:

Bundle c= getIntent().getExtras(); 
String s= c.getString("key"); 

在這段代碼c是空的,因爲Android將不設置任何額外到發射器Intent