Get Path and Filename from Camera intent result

前端 未结 3 2107
生来不讨喜
生来不讨喜 2020-12-14 09:20

I want to make a picture with the camera intent and save it to the default DCIM folder. Then I want to get the path/filename where the picture is stored.

I am trying

3条回答
  •  情深已故
    2020-12-14 10:05

    you can use like this in onActivityResult()

    if(requestCode==CAMERA_CAPTURE)
        {
    
            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 
                {
                    String picturePath =cursor.getString(cursor.getColumnIndex(Media.DATA));
                   Uri selectedImage = Uri.parse(picturePath);
    
                }
                while(cursor.moveToNext());
                    cursor.close();
                File out = new File(picturePath);
                try 
                {
                    mOriginal = decodeFile(out);
                }
                catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    
    
                mSelected.setImageBitmap(mOriginal);
            }
        }
    

提交回复
热议问题