siralam / BSImagePicker

An image picker that extends BottomSheetDialogFragment. Camera and gallery all in one dialog. Single or Multi Selection.
201 stars 62 forks source link

Can not perform this action after onSaveInstanceState #13

Closed aNnYvIrUs closed 6 years ago

aNnYvIrUs commented 6 years ago

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

siralam commented 6 years ago

May you provide a full stacktrace? Thanks.

aNnYvIrUs commented 6 years ago

Sure why not. If this problem solved then it will be so nice of you @siralam Thanks advance.

09-17 17:44:36.962 8837-8837/com.abc E/AndroidRuntime: FATAL EXCEPTION: main Process: com.abc, PID: 8837 java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2054) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:2077) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:678) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:632) at android.support.v4.app.DialogFragment.show(DialogFragment.java:143) at com.abc.activity.FolderDetails.onGalleryChoose(FolderDetails.java:454) at com.abc.utils.image_processing.imagecompressor.ImageUtil.takePermissionForGallery(ImageUtil.java:290) at com.abc.activity.BookKeeping$5.onClick(BookKeeping.java:276) at android.view.View.performClick(View.java:5647) at android.view.View$PerformClick.run(View.java:22465) at android.os.Handler.handleCallback(Handler.java:754) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:163) at android.app.ActivityThread.main(ActivityThread.java:6239) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

siralam commented 6 years ago

This exception occurs on your project but not in this library. Try google this error message and you will find a bunch of stackoverflows.

aNnYvIrUs commented 6 years ago

This error occurs in a below scenario

-Now go to the activity 'B' from 'A' and do nothing and come back to activity 'A'

Then click a button on 'A' to open picker dialog.

-I used this code to open picker dialog.

BSImagePicker pickerDialog = new BSImagePicker .Builder(BuildConfig.APPLICATION_ID + ".fileprovider") .setMaximumDisplayingImages(Integer.MAX_VALUE) .isMultiSelect() .setMinimumMultiSelectCount(1) .setMaximumMultiSelectCount(10) .setPeekHeight(dp2px(mActivity.getResources().getInteger(R.integer.peek_height))) .build();

pickerDialog..show(getSupportFragmentManager(), "picker");

I also google this error major of suggestion are to minor change in below method of your 'DialogFragment' class

public void show(FragmentManager manager, String tag) { mDismissed = false; mShownByMe = true; FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.commit(); // use commitAllowingStateLoss() instead of commit() }

On Mon, Sep 17, 2018 at 6:22 PM Sira notifications@github.com wrote:

This exception occurs on your project but not in this library. Try google this error message and you will find a bunch of stackoverflows.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/siralam/BSImagePicker/issues/13#issuecomment-421996430, or mute the thread https://github.com/notifications/unsubscribe-auth/AWJVVPMNz-vc5wzp5HPm4HAY1xHKo5_mks5ub5aggaJpZM4WipMk .