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?