1

I am trying to share video from Google Photos app to my App but not able to do so. I am not able to get the location of video where it is stored in the phone from the uri I have done it for Image sharing, that worked well with following code:

if (selectedImageUri.getAuthority() != null)
 {
    is = getContentResolver().openInputStream(selectedImageUri);
    Bitmap bmp = BitmapFactory.decodeStream(is);
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), bmp, "Title", null);

    Uri pathUri = Uri.parse(path);
    if (pathUri != null) {
        String[] filePathColumn = {MediaStore.MediaColumns.DATA};
        Cursor cursor = PreferenceHelper.getContext().getContentResolver()
                .query(pathUri, filePathColumn, null, null, null);
        cursor.moveToFirst();
        myPath = cursor.getString(cursor.getColumnIndex(filePathColumn[0]));
        File imgFile = new  File(myPath);
    } }

Snap of my manifest file:

android:name="android.intent.action.SEND"
android:name="android.intent.category.DEFAULT"
android:mimeType="image/*"
android:mimeType="video/*"
android:mimeType="audio/*"

I retrieve this intent action in my MainActivty. I fetch absolute path from Uri(Image and Video) then I convert it to bitmap and then send it to server. Sending Image and Video from Mobile Gallery app & file manager is some what easy but from Google photos app is tricky one. I managed for Images but for video there has to be something else, as above code will only work for Images.

Any solutions to find absolute path of Video from Google Photos app?

Ichigo Kurosaki
  • 3,765
  • 8
  • 41
  • 56
Rahul Lad
  • 411
  • 4
  • 10
  • What is the uri you are getting from photos app ? – Ichigo Kurosaki Dec 23 '15 at 09:03
  • 1
    Uri:content://com.google.android.apps.photos.contentprovider/0/2/mediaKey%3A%2FAF1QipOEj-tVrfDV8XuQT7No1UsRv9MFVOjjilqT3HNw/ACTUAL/1620909372 – Rahul Lad Dec 23 '15 at 09:06
  • This it the code for the image sharing, where is the code for video? What not working exactly? – shem Dec 23 '15 at 09:23
  • Yes above code is for image sharing. For video also I was using same code. is = getContentResolver().openInputStream(selectedImageUri); Bitmap bmp = BitmapFactory.decodeStream(is); here I am getting bmp null, obviously video can not be converted to bitmap. I am stucked how to proceed further. – Rahul Lad Dec 23 '15 at 09:31
  • Hi All, anybody find solution for this? – sandeepmaaram Aug 04 '16 at 15:40
  • still looking for a solution to this – Samuel Thompson Jan 20 '17 at 18:51
  • 2
    check this post: http://stackoverflow.com/questions/20559392/getting-videosnon-local-from-the-google-photos-app?rq=1 – Rahul Lad Feb 13 '17 at 11:09

0 Answers0