Intent + Share + Action_Send_Multiple + Facebook not working

后端 未结 2 1677
孤独总比滥情好
孤独总比滥情好 2021-01-14 00:26

I am trying to use Intent for sharing.It works well with single image or when I use Intent.ACTION_SEND.

But when i use Intent.ACTION_SEND_MULTIPLE It does not seems

2条回答
  •  情书的邮戳
    2021-01-14 01:19

    Further to the accepted answer (which I have upvoted) here is another method, which also closes the cursor:

    private Uri getContentUri(Context context, String contentPath) {
        Cursor c = context.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                new String[]{MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA},
                MediaStore.Images.ImageColumns.DATA + "=?",
                new String[]{contentPath},
                null
        );
    
        Uri contentUri = null;
        try {
            if (c != null && c.getCount() > 0 && c.moveToFirst()) {
                int colId = c.getColumnIndex(MediaStore.Images.ImageColumns._ID);
                if (colId > -1) {
                    int id = c.getInt(colId);
                    contentUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(id));
                }
            }
        } catch (Exception e) {
        } finally {
            try {
                if (c != null) {
                    c.close();
                }
            } catch (Exception e) {}
        }
        return contentUri;
    }
    

提交回复
热议问题