我有一个应用程序应该使用
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file) );
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Created in x");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Created in x");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
context.startActivity(Intent.createChooser(shareIntent, "Share via..."));
适用于 gmail 和其他选项,但当我尝试通过 FOURSQUARE 共享它时会崩溃。
02-14 12:59:55.714: E/AndroidRuntime(3072): FATAL EXCEPTION: main
02-14 12:59:55.714: E/AndroidRuntime(3072): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.joelapenna.foursquared/com.joelapenna.foursquared.CheckinComposeActivity2}: java.lang.NullPointerException
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.os.Looper.loop(Looper.java:130)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-14 12:59:55.714: E/AndroidRuntime(3072): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 12:59:55.714: E/AndroidRuntime(3072): at java.lang.reflect.Method.invoke(Method.java:507)
02-14 12:59:55.714: E/AndroidRuntime(3072): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-14 12:59:55.714: E/AndroidRuntime(3072): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-14 12:59:55.714: E/AndroidRuntime(3072): at dalvik.system.NativeStart.main(Native Method)
02-14 12:59:55.714: E/AndroidRuntime(3072): Caused by: java.lang.NullPointerException
02-14 12:59:55.714: E/AndroidRuntime(3072): at com.joelapenna.foursquared.CheckinComposeActivity2.handleSharePhotoFromGallery(CheckinComposeActivity2.java:626)
02-14 12:59:55.714: E/AndroidRuntime(3072): at com.joelapenna.foursquared.CheckinComposeActivity2.onCreate(CheckinComposeActivity2.java:139)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-14 12:59:55.714: E/AndroidRuntime(3072): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-14 12:59:55.714: E/AndroidRuntime(3072): ... 11 more
02-14 12:59:55.714: W/ActivityManager(110): Force finishing activity com.joelapenna.foursquared/.CheckinComposeActivity2
02-14 12:59:55.718: W/ActivityManager(110): Force finishing activity com.joelapenna.foursquared/.CheckinActivityAlt
有什么想法可能是错的吗?
谢谢!