getextra()putextra()有以下错误

时间:2014-10-02 14:59:33

标签: android

10-02 14:51:23.938: E/AndroidRuntime(1524): FATAL EXCEPTION: main
10-02 14:51:23.938: E/AndroidRuntime(1524): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mani/com.example.mani.MapActivity}: java.lang.NullPointerException
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.os.Looper.loop(Looper.java:137)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at java.lang.reflect.Method.invokeNative(Native Method)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at java.lang.reflect.Method.invoke(Method.java:511)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at dalvik.system.NativeStart.main(Native Method)
10-02 14:51:23.938: E/AndroidRuntime(1524): Caused by: java.lang.NullPointerException
10-02 14:51:23.938: E/AndroidRuntime(1524):     at com.example.mani.MapActivity.onCreate(MapActivity.java:25)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.Activity.performCreate(Activity.java:5104)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-02 14:51:23.938: E/AndroidRuntime(1524):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-02 14:51:23.938: E/AndroidRuntime(1524):     ... 11 more
10-02 14:55:46.319: E/AndroidRuntime(1784): FATAL EXCEPTION: main
10-02 14:55:46.319: E/AndroidRuntime(1784): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mani/com.example.mani.MapActivity}: java.lang.NullPointerException
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.os.Looper.loop(Looper.java:137)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at java.lang.reflect.Method.invokeNative(Native Method)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at java.lang.reflect.Method.invoke(Method.java:511)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at dalvik.system.NativeStart.main(Native Method)
10-02 14:55:46.319: E/AndroidRuntime(1784): Caused by: java.lang.NullPointerException
10-02 14:55:46.319: E/AndroidRuntime(1784):     at com.example.mani.MapActivity.onCreate(MapActivity.java:26)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.Activity.performCreate(Activity.java:5104)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-02 14:55:46.319: E/AndroidRuntime(1784):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-02 14:55:46.319: E/AndroidRuntime(1784):     ... 11 more

1 个答案:

答案 0 :(得分:1)

getExtras()方法返回Bundle,其中包含通过Intent传递的所有额外内容,但如果没有数据传递,则返回null。可能这是你问题的根源?