Comments (13)
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);
}
from tedbottompicker.
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.
from tedbottompicker.
What is your library version?
Let me know.
from tedbottompicker.
1.0.8 Version
from tedbottompicker.
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. :)
from tedbottompicker.
@DaniyarAmangeldy
Hm... I can not understand exactly.
Can you explain with error log?
from tedbottompicker.
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 tedbottompicker.
@DaniyarAmangeldy I think that is not library's problem.
Show me your source code.
Thanks you @prophet173
from tedbottompicker.
@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);
}
from tedbottompicker.
This was fixed in Pull #29
from tedbottompicker.
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.(Uri.java:475)
at android.net.Uri$StringUri.(Uri.java)
at android.net.Uri.parse(Uri.java:437)
at gun0912.tedbottompicker.TedBottomPicker.onActivityResultGallery(TedBottomPicker.java:566)
The issue is String realPath is null and it tries to do Uri.parse(realPath)
from tedbottompicker.
Is this issue resolved? I am getting crash if attempt to select photo is made.
from tedbottompicker.
me too having the same issue, unable to select photo from gallery and camera
from tedbottompicker.
Related Issues (20)
- ProxyActivity Issue.
- On select Google Photos
- Feature enhancement: Select Multiple images
- cant change background colour
- Mime type HOT 1
- 오타 수정 HOT 1
- Images don't load on Android 10+ HOT 9
- Open Camera throws exception on android 10 HOT 1
- Android Manifest Merge error, caused by file provider
- Do Not Have Gallery Option HOT 1
- Fatal Exception: java.lang.RuntimeException HOT 1
- Only shows external storage images
- How to add my own ImageProvider
- Not working for 1+ phones.
- No method explosed to change the span count of grid view
- Android 11 MediaScannerConnection.java line 250 android.media.MediaScannerConnection.lambda$scanFile$2
- picker를 내리거나 뒤로가기 했을때 콜백을 받지 못하나요?
- Could not resolve all files for configuration ':app:debugRuntimeClasspath'. HOT 1
- android 13 WRITE_EXTERNAL_STORAGE 퍼미션 문제
- Could not find gun0912.ted:tedbottompicker:2.0.1.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tedbottompicker.