我制作了一个简单的Android应用程序,它在一个长度为5的编辑文本输入上从一个活动移动到另一个活动。但我得到了例外。我附加了两个java文件(MainActicity和另一个),mainfest文件和logcat输出。有人请帮助我。 提前致谢。
下载链接:: 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 :(得分:1)
在Another
课程中:
Bundle c= getIntent().getExtras();
String s= c.getString("key");
在此代码中c
为空,因为android不会为启动器Intent
设置任何额外内容。