2011-10-19 9 views
2

Gmailアプリケーションと画像の共有に問題があります。 これは私のコードです。Gmailアプリケーションと画像を共有できません。

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);  
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.mail_subject)); 
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.mail_body)); 
    emailIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.facebook_share_text)); 


    //Download the image first 
    String location=downloadImage(true); 
    File root=android.os.Environment.getExternalStorageDirectory(); 
    Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location); 

    //Add attachment 
    emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+root.getAbsolutePath()+"/"+location)); 

    emailIntent.setType("image/jpeg"); 
    startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by))); 

デフォルトのメールアプリは、偉大な働いているFacebookで共有が動作するように偉大な、Gmailのアプリケーション縫い目が機能していますが、添付ファイルとして表示されているが、添付ファイルは、送信されていません。

ここにスクリーンショットがあります。 All share options Email is send but without attachment, although the attachment is displayed here Facebook share is perfect

ので助けてください。

答えて

3
String location=downloadImage(true); 
File root=android.os.Environment.getExternalStorageDirectory(); 
Log.e("send from where:","file:///"+root.getAbsolutePath()+"/"+location); 

//Add attachment 
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+ 
root.getAbsolutePath()+"/"+location)); 
// replace "Uri.parse" with Uri.fromFile(new File("file:///"+ 
root.getAbsolutePath()+"/"+location)) 
emailIntent.setType("image/jpeg"); 
startActivity(Intent.createChooser(emailIntent, getString(R.string.share_by))); 

このことは実際に私のために働いた。同じことが、私がUri.parseを送ったときに起こります。添付ファイルのサイズは0 kbになります。しかし、私がそれを変更すると、うまくいった。

0

共有画像もFacebookの、のWhatsAppは、Gmail、Bluetooth対応に取り組んでおり、メッセージ

  Uri imageUri = Uri.fromFile(file); 
      Intent shareIntent = new Intent(); 
      shareIntent.setAction(Intent.ACTION_SEND); 
      shareIntent.putExtra(Intent.EXTRA_STREAM,imageUri); 
      shareIntent.setType("image/*"); 
      shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
      startActivity(Intent.createChooser(shareIntent,"Share with..")); 
関連する問題