2

i am a new android developer and in my app i want to send an image via email which is placed in Assets folder and the mailer view shows 0 kb size of image attachment but the name of image is properly shown and here is my code is:

 try {
   Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
   picMessageIntent.setType("image/png");

  String str = "image.png"                 
  String imageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath()+"file:///android_asset/Images/" + str;

  File downloadedPic = new File(imageDirectoryPath);
 picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
                                                    startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
 } catch (Exception e) {
    Toast.makeText(MyActivity.this, "No handler", Toast.LENGTH_LONG).show();
  }

Pleas give me any suggestion... Thanx in Advance...

4

1 回答 1

0

MIME 类型有问题 更改 MIME 类型并重试。

picMessageIntent.setType("image/*");

或者

picMessageIntent.setType("image/jpg");
于 2012-05-02T11:15:39.837 回答