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.
This commit is contained in:
parent
0e84a12140
commit
cbdfebc632
1 changed files with 21 additions and 0 deletions
|
@ -94,6 +94,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
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) {
|
if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {
|
||||||
try {
|
try {
|
||||||
Bitmap bm = BitmapFactory.decodeFile(path);
|
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) {
|
if (bm != null) {
|
||||||
FileUploadPrepareTask task = new FileUploadPrepareTask(getActivity(), path, imageSize);
|
FileUploadPrepareTask task = new FileUploadPrepareTask(getActivity(), path, imageSize);
|
||||||
task.execute(bm);
|
task.execute(bm);
|
||||||
|
|
Loading…
Reference in a new issue