How to attach a Bitmap when launching ACTION_SEND intent

后端 未结 4 1078
無奈伤痛
無奈伤痛 2020-12-05 00:44

I have this code:

 Intent intent = new Intent(); 
 intent.setAction(Intent.ACTION_SEND); 
 startActivity(intent); 

Which will successfully

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 01:16

        String pathofBmp = Images.Media.insertImage(getContentResolver(), bitmap,"title", null);
        Uri bmpUri = Uri.parse(pathofBmp);
        final Intent emailIntent1 = new Intent(     android.content.Intent.ACTION_SEND);
        emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
        emailIntent1.setType("image/png");
    

    Where bitmap is your bitmap object which must be store in SD Card. and then use that Uri for shareimage.

提交回复
热议问题