jrvansuita / PickImage

📸 🖼️ Shows a DialogFragment with camera and gallery options. User can choose which provider wants to pick images from.
MIT License
469 stars 107 forks source link

Activity destroyed #23

Closed sayah-y closed 2 years ago

sayah-y commented 7 years ago

Hello @jrvansuita ,

Sometimes the app has low memory before the pick intent (camera or gallery). So, activity is destroyed. Does the library manage this situation ? It seems that I have this issue sometimes.

Thanks.

jrvansuita commented 7 years ago

Hi @sayah-y, the answer is no, the library doesn't handle this situation. One time a got this bug and tried to implement that. But never more I got it, so I let the bug. Can you help me to fix this?

GuilhE commented 7 years ago

Having the same problem:

d.app.ActivityThread$H.handleMessage(ActivityThread.java:1537) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) Caused by java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:650) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609) at android.support.v4.app.DialogFragment.show(DialogFragment.java:143) at com.vansuita.pickimage.dialog.PickImageDialog.show(PickImageDialog.java:56) at com.vansuita.pickimage.dialog.PickImageDialog.show(PickImageDialog.java:52)

jrvansuita commented 7 years ago

Yeap, @GuilhE can you help me to solve this issue? I'm completely out of time to fix this now.

GuilhE commented 7 years ago

@jrvansuita Let me see what I can do.

GuilhE commented 7 years ago

I haven't noticed your lib provides permission logic, which it's cool. I was managing it with Dexter and after being granted permission I was calling this:


if (!mActivity.isFinishing() && callback != null) {
            PickImageDialog.build(
                    new PickSetup()...
                    .show(mActivity);

And it was failing in some devices. I'm not using Dexter to check Camera permissions now, and it's working. Later, with more time and patience I'll give it a second try and see if it's something in your code or not.

jrvansuita commented 7 years ago

Hi, any news about it?

GuilhE commented 7 years ago

Not yet, I had to move on with the project. The use case, If you want to test it, is to request permissions with Dexter instead of your lib. Inside the success callback add: PickImageDialog.build...show(activity). This will throw in some devices.

jairobjunior commented 6 years ago

I am having the same problem of the activity being destroyed. It is 100% reproducible when you enable the option "Don't keep activities" from dev options.

I haven't had time to go though the code, but it sounds like a field not being saved, maybe on the onSaveInstanceState.