photo share intent in android

前端 未结 3 1707
庸人自扰
庸人自扰 2020-12-12 02:58
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType(\"image/*\");

Uri uri = U         


        
3条回答
  •  萌比男神i
    2020-12-12 03:25

    Try this

    Bitmap icon = mBitmap;
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("image/jpeg");
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
        File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
        try {
            f.createNewFile();
            FileOutputStream fo = new FileOutputStream(f);
            fo.write(bytes.toByteArray());
        } catch (IOException e) {                       
                e.printStackTrace();
        }
        share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
        startActivity(Intent.createChooser(share, "Share Image"));
    

    Refer more links

    http://android-developers.blogspot.in/2012/02/share-with-intents.html

    Android Share Via Dialog

    Image post into facebook wall from android sdcard

提交回复
热议问题