2011-10-19 3 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))); 

기본 이메일 응용 프로그램은 큰 노력하고 페이스 북 친구들과 공유 일을 큰, 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을 보낼 때 일어난다. 첨부 파일의 크기가 0kb로 표시됨을 알 수 있습니다. 그러나 내가 그것을 바꿀 때, 그것은 잘 작동했다.

0

공유 이미지 또한 페이스 북, 싸이 월드, 미투데이, Gmail은, 블루투스 작업과 메시지

  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..")); 
관련 문제