Sharing Bitmap via Android Intent

后端 未结 8 1556
名媛妹妹
名媛妹妹 2020-12-02 17:35

In my android app, I have a bitmap (say b) and a button. Now when I click on the button, I want to share the bitmap. I am making use of the below code inside my onClic

8条回答
  •  一生所求
    2020-12-02 17:39

    private void sharePalette(Bitmap bitmap) {
    
     String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "palette", "share palette");
        Uri bitmapUri = Uri.parse(bitmapPath);
    
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/png");
        intent.putExtra(Intent.EXTRA_STREAM, bitmapUri);
        startActivity(Intent.createChooser(intent, "Share"));
    }
    

提交回复
热议问题