Getting Uri Null in capture photo from camera intent in samsung mobile

后端 未结 3 1571
情歌与酒
情歌与酒 2021-01-03 12:35

I am getting null in contenturi in samsung phones while capturing photo from camera but rest of others phones its working fine.

@Override 
    protected void         


        
3条回答
  •  离开以前
    2021-01-03 13:20

    This above code works in some mobile but does not work in samsung mobile in my case, so I implemented the common logic for all devices.

    After capturing the photo from camera, I implement a logic using Cursor and iterate the cursor to get the path of last captured photo from camera.The below code works fine on any device.

    Cursor cursor = getContentResolver().query(Media.EXTERNAL_CONTENT_URI, new String[]{Media.DATA, Media.DATE_ADDED, MediaStore.Images.ImageColumns.ORIENTATION}, Media.DATE_ADDED, null, "date_added ASC");
    if(cursor != null && cursor.moveToFirst())
    {
        do {
            uri = Uri.parse(cursor.getString(cursor.getColumnIndex(Media.DATA)));
            photoPath = uri.toString();
        }while(cursor.moveToNext());
        cursor.close();
    }
    

提交回复
热议问题