2016-05-23 36 views
0

嘗試使用下面的代碼及其正在運行的圖像,但不通過消息傳遞文本,它可以很好地處理電子郵件,whatsapp。任何一個可以建議我該怎麼辦呢圖像和文字不會一次通過android消息傳遞

Uri shareImageUri = saveBitmapImage(result); 
       final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 

       emailIntent.putExtra(Intent.EXTRA_STREAM, shareImageUri); 
       emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Hiiiiiiiiiiiiiiiiiiiiiiii"); 
       emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"byeeeeeeeeeeee"); 

       emailIntent.setType("image/png"); 
       mActivity.startActivity(Intent.createChooser(emailIntent, "Send mail...")); 

回答

0

試試這個代碼:

String fileName = "image_file_name.jpg";//Name of an image 
String externalStorageDirectory = Environment.getExternalStorageDirectory().toString(); 
String myDir = externalStorageDirectory + "/saved_images/"; // the file will be in saved_images 
Uri uri = Uri.parse("file:///" + myDir + fileName); 
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); 
shareIntent.setType("text/html"); 
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test Mail"); 
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Launcher"); 
shareIntent.putExtra(Intent.EXTRA_STREAM, uri); 
startActivity(Intent.createChooser(shareIntent, "Share Image and Text")); 

File filePath = getFileStreamPath("share_image.jpg"); //optional //internal storage 
    Intent shareIntent = new Intent(); 
    shareIntent.setAction(Intent.ACTION_SEND); 
    shareIntent.putExtra(Intent.EXTRA_TEXT, "share content"); 
    shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath))); //optional//use this when you want to send an image 
    shareIntent.setType("image/jpeg"); 
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    startActivity(Intent.createChooser(shareIntent, "share")); 
+0

它不工作和文本不顯示 – srinu