Android 共享图像只适用于Facebook,而不适用于twitter或电子邮件

Android 共享图像只适用于Facebook,而不适用于twitter或电子邮件,android,Android,我实现了共享代码,它看起来像在StackOverflow上搜索时发现的任何其他代码 String pathToExportedFile = getPath(); // Export for share Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/jpeg"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + pathToExpo

我实现了共享代码,它看起来像在StackOverflow上搜索时发现的任何其他代码

String pathToExportedFile = getPath();

// Export for share
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");

share.putExtra(Intent.EXTRA_STREAM,
  Uri.parse("file:///" + pathToExportedFile));

share.putExtra(Intent.EXTRA_SUBJECT, "See Attachment");

model.activity.startActivity(Intent.createChooser(share, "Select a way to Share"));
然而,它只适用于Facebook。当我选择gmail时,它看起来像是附加的,但当我收到电子邮件时却没有附加。当我通过Twitter这样做时,它说它找不到附件

附加的图像文件位于sdcard\DCIM\Camera中

请帮忙

-毫升

更新:

我的文件路径很好,但看起来gmail正在垃圾收集它?以下是一些精选的ADB日志:

02-01 16:36:46.720: D/Gmail(1896): Cached file:///mnt/sdcard/DCIM/Camera/1328132065637.jpg to /data/data/com.google.android.gm/cache/2012-02-01-16:36:46428133821.attachment
02-01 16:36:46.880: D/Gmail(1896): MailProvider.insert(): added local message 140
02-01 16:36:47.100: I/Gmail(1896): MainSyncRequestProto: lowestBkwdConvoId: 0, highestHandledServerOp: 554429, normalSync: true
02-01 16:36:49.900: I/Gmail(1896): MainSyncRequestProto: lowestBkwdConvoId: 0, highestHandledServerOp: 554462, normalSync: true
02-01 16:36:51.650: D/Gmail(1896): Cleaning up cached attachment: /data/data/com.google.android.gm/cache/2012-02-01-16:36:46428133821.attachment
02-01 16:36:51.650: D/Gmail(1896): Updating message 1392647555039793989. synced=true
02-01 16:36:52.230: I/Gmail(1896): MainSyncRequestProto: lowestBkwdConvoId: 0, highestHandledServerOp: 554477, normalSync: true
有人有线索吗?

这里有类似的问题:

也有同样的问题

来自adb logcat:

V/DumbDumpersMain( 3972):   sPhotoUri=file://sdcard/DumbDumpers/DumbDumper.jpg
I/ActivityManager(   56):   Starting activity: Intent { action=android.intent.action.CHOOSER comp={android/com.android.internal.app.ChooserActivity} (has extras) }
I/ActivityManager(   56):   Starting activity: Intent { action=android.intent.action.SEND type=jpeg/image flags=0x3000000 comp={com.google.android.gm/com.google.android.gm.ComposeActivityGmail} (has extras) }
I/ActivityManager(   56):   Starting activity: Intent { action=android.intent.action.SEND type=jpeg/image flags=0x2800000 comp={com.google.android.gm/com.google.android.gm.ComposeActivity} (has extras) }
D/gmail-ls(  120):      MailProvider.query: content://gmail-ls/labels/me@gmail.com(null, null)
D/Gmail   ( 2507):      URI FOUND:file://sdcard/DumbDumpers/DumbDumper.jpg
看起来电子邮件提供程序正在附加长度为0的文件。当我检查文件系统时,文件就在那里并且正确无误。创建图像文件的代码在尝试通过电子邮件发送之前已经完成

更新

我的道路应该是

file:///sdcard/DumbDumpers/DumbDumper.jpg

您需要额外的/因为它指向根目录,即:

文件://+//sdcard/DumbDumpers/DumbDumper.jpg

合并为

file:///sdcard/DumbDumpers/DumbDumper.jpg

在上面的代码片段中,您需要:

emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ sPhotoFileName));
我希望这有帮助。调试花了我很多时间

问候,,
Finlay

我从未见过twitter允许分享图片。因为它只发布推文。但是您可以添加一个ImageURL。您可以尝试:uri=uri.fromfilenewfileenvironment.getExternalStorageDirectory,FILENAME;而不是使用文件:///