Get Image path from camera intent

前端 未结 7 1670
轮回少年
轮回少年 2021-01-05 13:15

There is option of capture image from camera in my application.But there is problem to get image from camera. When i use ACTION_IMAGE_CAPTURE this it return nul

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 13:47

     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 = Uri.parse(cursor.getString(cursor.getColumnIndex(Media.DATA)));
                     String photoPath = uri.toString();
                 }while(cursor.moveToNext());
    
    
                 cursor.close();
             }
    

    when while loop doing the last itration it give the image path which in captured last time.

提交回复
热议问题