GithubHelp home page GithubHelp logo

Comments (13)

hexlay avatar hexlay commented on September 12, 2024 3

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.

anurags2102 avatar anurags2102 commented on September 12, 2024 3

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.

ParkSangGwon avatar ParkSangGwon commented on September 12, 2024

What is your library version?
Let me know.

from tedbottompicker.

DaniyarAmangeldy avatar DaniyarAmangeldy commented on September 12, 2024

1.0.8 Version

from tedbottompicker.

DaniyarAmangeldy avatar DaniyarAmangeldy commented on September 12, 2024

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.

ParkSangGwon avatar ParkSangGwon commented on September 12, 2024

@DaniyarAmangeldy
Hm... I can not understand exactly.
Can you explain with error log?

from tedbottompicker.

DaniyarAmangeldy avatar DaniyarAmangeldy commented on September 12, 2024

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.

ParkSangGwon avatar ParkSangGwon commented on September 12, 2024

@DaniyarAmangeldy I think that is not library's problem.
Show me your source code.
Thanks you @prophet173

from tedbottompicker.

DaniyarAmangeldy avatar DaniyarAmangeldy commented on September 12, 2024
    @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.

gtcompscientist avatar gtcompscientist commented on September 12, 2024

This was fixed in Pull #29

from tedbottompicker.

StephenMilone avatar StephenMilone commented on September 12, 2024

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.

paramvir88 avatar paramvir88 commented on September 12, 2024

Is this issue resolved? I am getting crash if attempt to select photo is made.

from tedbottompicker.

ursrudra avatar ursrudra commented on September 12, 2024

me too having the same issue, unable to select photo from gallery and camera

from tedbottompicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.