我想得到一个额外的字符串,但我收到了这个错误,我无法弄清楚问题出在哪里:
这是我如何放置额外内容:
Intent i = new Intent(Hoteli.this, ListingDetails.class);
i.putExtra(hoteli.get(position).getImage(), "listing_image");
以及我如何获得额外费用:
Bundle extras = getIntent().getExtras();
String imgURL=extras.getString("listing_image");
Log.v("--", imgURL);
这是我的 LogCat 输出:
06-02 13:51:27.561: E/AndroidRuntime(535): FATAL EXCEPTION: main
06-02 13:51:27.561: E/AndroidRuntime(535): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.biznismap.com/com.biznismap.com.activities.ListingDetails}: java.lang.NullPointerException: println needs a message
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.os.Looper.loop(Looper.java:123)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-02 13:51:27.561: E/AndroidRuntime(535): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 13:51:27.561: E/AndroidRuntime(535): at java.lang.reflect.Method.invoke(Method.java:521)
06-02 13:51:27.561: E/AndroidRuntime(535): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-02 13:51:27.561: E/AndroidRuntime(535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-02 13:51:27.561: E/AndroidRuntime(535): at dalvik.system.NativeStart.main(Native Method)
06-02 13:51:27.561: E/AndroidRuntime(535): Caused by: java.lang.NullPointerException: println needs a message
06-02 13:51:27.561: E/AndroidRuntime(535): at android.util.Log.println_native(Native Method)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.util.Log.v(Log.java:101)
06-02 13:51:27.561: E/AndroidRuntime(535): at com.biznismap.com.activities.ListingDetails.getExtras(ListingDetails.java:34)
06-02 13:51:27.561: E/AndroidRuntime(535): at com.biznismap.com.activities.ListingDetails.init(ListingDetails.java:51)
06-02 13:51:27.561: E/AndroidRuntime(535): at com.biznismap.com.activities.ListingDetails.onCreate(ListingDetails.java:28)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-02 13:51:27.561: E/AndroidRuntime(535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-02 13:51:27.561: E/AndroidRuntime(535): ... 11 more