From cbdfebc632f90900aa7d95f2144ab3a936657092 Mon Sep 17 00:00:00 2001 From: Aniruddh Bhilvare Date: Tue, 17 Oct 2017 15:07:36 +0530 Subject: [PATCH] Solved issue of image not picked from Photo's App If we select image from Google's Photos app. It wasn't getting selected due to invalid image path error. Thus it was returning null Bitmap, which is solved in this patch. --- src/android/org/linphone/ChatFragment.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/android/org/linphone/ChatFragment.java b/src/android/org/linphone/ChatFragment.java index f1cc2f8a9..325bfddcf 100644 --- a/src/android/org/linphone/ChatFragment.java +++ b/src/android/org/linphone/ChatFragment.java @@ -94,6 +94,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.lang.ref.WeakReference; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -798,6 +799,26 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) { try { Bitmap bm = BitmapFactory.decodeFile(path); + + if (bm == null && path.contains("NONE")) { + Uri uri = Uri.parse(path); + InputStream is = null; + if (uri.getAuthority() != null) { + try { + is = getActivity().getContentResolver().openInputStream(uri); + bm = BitmapFactory.decodeStream(is); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + if (bm != null) { FileUploadPrepareTask task = new FileUploadPrepareTask(getActivity(), path, imageSize); task.execute(bm);