How to show an image through an intent being compatible with different apps

前端 未结 4 938
Happy的楠姐
Happy的楠姐 2021-01-03 12:22

I\'m trying to share an image I have previously saved on disk, sending an Intent.ACTION_SEND. The problem is that I can\'t find a way to be compatible with diff

4条回答
  •  日久生厌
    2021-01-03 13:08

    try

    intent.setType("image/*");
    

    for me it works for twitter, whatsapp, bluetooth....

    EDIT: full code:

    Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND);
            intent.setType("image/*");
    
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
            intent.putExtra(android.content.Intent.EXTRA_TEXT, R.string.visita);
            Uri uri = Uri
            .parse("android.resource://com.package.xname/drawable/"
                    + i);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
    

提交回复
热议问题