Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Crash when requesting permission and rotating device #15

Open
CarsonRedeye opened this issue Sep 27, 2019 · 1 comment
Open

Crash when requesting permission and rotating device #15

CarsonRedeye opened this issue Sep 27, 2019 · 1 comment
Labels
bug Something that needs to be fixed.

Comments

@CarsonRedeye
Copy link

CarsonRedeye commented Sep 27, 2019

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=196688, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {....application.MainActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4588)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4630)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:6990)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
     Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at androidx.fragment.app.FragmentManagerImpl.checkStateLoss(FragmentManagerImpl.java:1536)
        at androidx.fragment.app.FragmentManagerImpl.enqueueAction(FragmentManagerImpl.java:1558)
        at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:317)
        at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:282)
        at com.afollestad.assent.internal.ExtensionsKt.transact(Extensions.kt:85)
        at com.afollestad.assent.internal.PermissionFragment.detach$com_afollestad_assent(PermissionFragment.kt:49)
        at com.afollestad.assent.internal.Assent$Companion.forgetFragment(Assent.kt:84)
        at com.afollestad.assent.internal.PermissionFragmentKt.onPermissionsResponse(PermissionFragment.kt:116)
        at com.afollestad.assent.internal.PermissionFragment.onRequestPermissionsResult(PermissionFragment.kt:68)
        at androidx.fragment.app.FragmentActivity.onRequestPermissionsResult(FragmentActivity.java:769)
        at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7940)
        at android.app.Activity.dispatchActivityResult(Activity.java:7762)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4581)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4630) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:6990) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445

Library Version:

2.3.1

Affected Device(s):

Note 9 with API 28

Describe the Bug:
Permission dialog crashes after rotation

To Reproduce:

  1. Open a fragment that requires a permission with runWithPermissions
  2. Wait for the permissions alert
  3. Rotate the device
  4. Press Allow or deny
    RESULT: Crash

Expected Behavior:

No Crash

@CarsonRedeye CarsonRedeye added the bug Something that needs to be fixed. label Sep 27, 2019
@CarsonRedeye
Copy link
Author

The workaround for now is to use activity?.runWithPermissions in my fragment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that needs to be fixed.
Projects
None yet
Development

No branches or pull requests

1 participant