Teilen Bild via android-app mit ACTION_SEND nicht funktioniert

Habe ich Biene nach dieser

Android - Anteil auf Facebook, Twitter, E-Mail, ecc

Aber ich bin nicht in der Lage zu teilen, Bild mit action_send intent in android.Bitte siehe meinen code, und leite mich, wo ich falsch bin.

saveFileName = "";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
Bitmap shareImage = null;
shareImage = Bitmap.createBitmap(pc.getDrawingCache());
OutputStream OS = null;
File f1 = new File(Environment.getExternalStorageDirectory()
+ "/Free Hand");
if (f1.isDirectory() == false)
new File(Environment.getExternalStorageDirectory()
+ "/Free Hand").mkdir();
SimpleDateFormat filename = new SimpleDateFormat("yyyyMMddHmmss");
java.util.Date today1 = new java.util.Date();
saveFileName = filename.format(new java.sql.Timestamp(today1
.getTime())) +  ".png";
if (saveFileName.length() == 0)
saveFileName = "Free Hand";
file = new File(Environment.getExternalStorageDirectory()
+ "/Free Hand", saveFileName);
try {
outStream = new FileOutputStream(file);
shareImage.compress(Bitmap.CompressFormat.PNG, 100, outStream);
share.putExtra(android.content.Intent.ACTION_SEND, Uri.parse(Environment.getExternalStorageDirectory()
+ "/Free Hand/"+saveFileName+".png"));
Toast.makeText(
getApplicationContext(),
"Saved in " + Environment.getExternalStorageDirectory()
+ "/Free Hand" + "\nFile: " + saveFileName
+ ".png", Toast.LENGTH_LONG).show();
Log.v("Before image", "Before image");
startActivity(Intent.createChooser(share, "Share Image"));
Log.v("After image", "After image");
outStream.flush();
outStream.close();
saveFileName = "";
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"Exception : " + e.getMessage(), Toast.LENGTH_LONG)
.show();
}
save = false;

Die Logcat Ausgabe die ich bekomme, ist :

06-18 16:08:16.274: D/StatusBarPolicy(1378): [BRIGHTHY] 3. Show 3G indicator
06-18 16:08:17.791: W/ActivityManager(1378): Launch timeout has expired, giving up wake lock!
06-18 16:08:17.804: W/ActivityManager(1378): Activity idle timeout for HistoryRecord{454dabf8 com.facebook.katana/.ComposerActivity}
06-18 16:08:18.004: D/LGE_data(1463): LGE_Fast_Dormancy) new_state(2) i=(0) lastPDPstate=(2)
06-18 16:08:18.124: W/ResponseProcessCookies(15476): Invalid cookie header: "Set-Cookie: datr=HgbfT5h8NEIMcQRt7EurBx16; expires=Wed, 18-Jun-2014 10:42:38 GMT; path=/; domain=.facebook.com; httponly". Unable to parse expires attribute: Wed
06-18 16:08:18.644: D/ACRA(15476): #checkAndSendReports - finish
06-18 16:08:18.684: E/AndroidRuntime(15476): FATAL EXCEPTION: main
06-18 16:08:18.684: E/AndroidRuntime(15476): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.katana/com.facebook.katana.ComposerActivity}: java.lang.NullPointerException
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.os.Looper.loop(Looper.java:123)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread.main(ActivityThread.java:4627)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at java.lang.reflect.Method.invokeNative(Native Method)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at java.lang.reflect.Method.invoke(Method.java:521)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at dalvik.system.NativeStart.main(Native Method)
06-18 16:08:18.684: E/AndroidRuntime(15476): Caused by: java.lang.NullPointerException
06-18 16:08:18.684: E/AndroidRuntime(15476):    at com.facebook.katana.activity.media.Storage.a(Storage.java:140)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at com.facebook.katana.ComposerActivity.a(ComposerActivity.java:742)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at com.facebook.orca.activity.FbFragmentActivity.onCreate(FbFragmentActivity.java:48)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-18 16:08:18.684: E/AndroidRuntime(15476):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-18 16:08:18.684: E/AndroidRuntime(15476):    ... 11 more
06-18 16:08:18.714: W/ActivityManager(1378):   Force finishing activity com.facebook.katana/.ComposerActivity
06-18 16:08:19.214: W/ActivityManager(1378): Activity pause timeout for HistoryRecord{454dabf8 com.facebook.katana/.ComposerActivity}
06-18 16:08:19.574: W/Flex(1378): getString FLEX_COUNTRY_CODE COM
06-18 16:08:19.574: W/Flex(1378): getString FLEX_OPERATOR_CODE OPEN
06-18 16:08:19.574: W/Flex(1378): getString FLEX_OPERATOR_CODE OPEN
06-18 16:08:19.574: W/Flex(1378): getString FLEX_COUNTRY_CODE COM
06-18 16:08:19.574: W/Flex(1378): getString FLEX_OPERATOR_CODE OPEN
06-18 16:08:19.574: D/StatusBarPolicy(1378): [BRIGHTHY] 0. mDataNetType: 8
06-18 16:08:19.574: D/StatusBarPolicy(1378): [BRIGHTHY] curNetwork=40420 curHPLMN=40420

Ich bin es zu testen auf einem echten Gerät über USB-debugging.

InformationsquelleAutor Shruti | 2012-06-18
Schreibe einen Kommentar