-4

我制作了一个简单的 android 应用程序,它在长度为 5 的编辑文本输入上从一个活动移动到另一个活动。但我得到了例外。我附加了两个 java 文件(MainActicity 和另一个),mainfest 文件和 logcat 输出。有人请帮帮我。提前致谢。

下载链接::http ://www.4shared.com/folder/gyDYjAYC/AndroidApp.html

日志猫是:

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
4

1 回答 1

1

在你的Another课堂上:

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

在此代码c中为 null,因为 android 不会为启动器设置任何额外内容Intent

于 2012-08-10T11:34:42.020 回答