Open DaniyarAmangeldy opened 7 years ago
What is your library version? Let me know.
1.0.8 Version
It happens , because image is not in external storage.. And when your ActivityResult tries find file in external storage by Uri.getPath(); it crashes. Need to download image from google photo first, then set it. :)
@DaniyarAmangeldy Hm... I can not understand exactly. Can you explain with error log?
You can see this problem http://stackoverflow.com/questions/34599055/retrieve-image-from-google-photos-library-after-dowloading
Here is log of failure :
02-22 15:42:28.257 12586-12586/marsstudio.myrent E/AndroidRuntime: FATAL EXCEPTION: main Process: marsstudio.myrent, PID: 12586 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/0/1/mediakey:/local%3Abdd22366-cbdd-490d-a3d9-9f5ca971e923/ORIGINAL/NONE/667693682 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/0/1/mediakey%3A%2Flocal%253Abdd22366-cbdd-490d-a3d9-9f5ca971e923/ORIGINAL/NONE/667693682} }} to activity {marsstudio.myrent/marsstudio.myrent.presentation.views.activities.acSettings}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:4089) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132) at android.app.ActivityThread.-wrap20(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.lang.NullPointerException at java.io.File.<init>(File.java:262) at gun0912.tedbottompicker.TedBottomPicker.onActivityResultGallery(TedBottomPicker.java:529) at gun0912.tedbottompicker.TedBottomPicker.onActivityResult(TedBottomPicker.java:481) at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:164) at android.app.Activity.dispatchActivityResult(Activity.java:6932) at android.app.ActivityThread.deliverResults(ActivityThread.java:4085) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132) at android.app.ActivityThread.-wrap20(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
From above solution link, here`s my workaround: but be aware, this will insert image into Picture directory, so eventually storage problems may appear on low-end devices? P.S pull request created
private void onActivityResultGallery(Intent data) {
Uri temp = data.getData();
if (temp == null) {
errorMessage();
}
if (temp.toString().startsWith("content://com.google.android.apps.photos.content")){
try {
InputStream is = getActivity().getContentResolver().openInputStream(temp);
if (is != null) {
Bitmap pictureBitmap = BitmapFactory.decodeStream(is);
String realPath = RealPathUtil.getRealPath(getActivity(), getImageUri(getActivity(), pictureBitmap));
Uri selectedImageUri = Uri.fromFile(new File(realPath));
complete(selectedImageUri);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
String realPath = RealPathUtil.getRealPath(getActivity(), temp);
Uri selectedImageUri = Uri.fromFile(new File(realPath));
complete(selectedImageUri);
}
}
public Uri getImageUri(Context context, Bitmap bitmap) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, "img", null);
return Uri.parse(path);
}
@DaniyarAmangeldy I think that is not library's problem. Show me your source code. Thanks you @prophet173
@OnClick(R.id.rv_item_create_icon_camera)
public void setPhoto(){
new TedBottomPicker.Builder(context)
.showTitle(false)
.setSelectMaxCount(20 - images.size())
.setOnMultiImageSelectedListener(this)
.setCompleteButtonText(R.string.string_done)
.setSelectMaxCountErrorText(R.string.string_max_photo)
.create()
.show(manager);
}
@Override
public void onImagesSelected(ArrayList<Uri> uriList) {
for(Uri uri: uriList){
images.add(uri.getPath());
}
notifyDataSetChanged();
((acCreateApartment) context).setApartmentPhotos(images);
}
This was fixed in Pull #29
I'm still having this crash happen on 1.0.12.
From bottom sheet, tap gallery, which loads google photos, select a photo not on the device, see the google photos downloading dialog, then crash.
Let me know if you need more info, the stack trace points here:
Caused by: java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.
The issue is String realPath is null and it tries to do Uri.parse(realPath)
Is this issue resolved? I am getting crash if attempt to select photo is made.
me too having the same issue, unable to select photo from gallery and camera
Hi,
I am doing deeplinking in my app. So I've opened google photos and by tap on share icon, opening my app and sending image path. I am getting following path in intent:
content://com.google.android.apps.photos.contentprovider/0/1/mediakey:/local%253A02ae48d5-e576-449b-994f-1db260da79c0/REQUIRE_ORIGINAL/NONE/2022132799
When I tried to find actual path of image for downloading image it is crashing. But If I tried to download a image that still exists on device then it works. Please tell me what I can do for this. It was working perfectly before.
Selecting local images works ok, but when I select some image not from file:// , but content:// , it crashes