canelmas / let

Annotation based simple API flavored with AOP to handle new Android runtime permission model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delayed execution failed error when asking for multiple permissions

izBasit opened this issue · comments

For your reference.

FATAL EXCEPTION: main

Process: com.mobility.iz.tstar, PID: 13347

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.mobility.iz.tstar/com.mobility.ui.DashboardActivity}: com.canelmas.let.LetException: Delayed Execution Failed!

    at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)

    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)

    at android.app.ActivityThread.-wrap16(ActivityThread.java)

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)

    at android.os.Handler.dispatchMessage(Handler.java:102)

    at android.os.Looper.loop(Looper.java:148)

    at android.app.ActivityThread.main(ActivityThread.java:5417)

    at java.lang.reflect.Method.invoke(Native Method)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

 Caused by: com.canelmas.let.LetException: Delayed Execution Failed!

    at com.canelmas.let.Let.handle(Let.java:74)

    at com.mobility.ui.DashboardActivity.onRequestPermissionsResult(DashboardActivity.java:71)

    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6582)

    at android.app.Activity.dispatchActivityResult(Activity.java:6460)

    at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)

    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 

    at android.app.ActivityThread.-wrap16(ActivityThread.java) 

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 

    at android.os.Handler.dispatchMessage(Handler.java:102) 

    at android.os.Looper.loop(Looper.java:148) 

    at android.app.ActivityThread.main(ActivityThread.java:5417) 

    at java.lang.reflect.Method.invoke(Native Method) 

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

 Caused by: com.canelmas.let.LetException: Future Task execution failed!

    at com.canelmas.let.DelayedTasks$Task.call(DelayedTasks.java:68)

    at com.canelmas.let.DelayedTasks$Task.execute(DelayedTasks.java:59)

    at com.canelmas.let.Let.handle(Let.java:72)

    at com.mobility.ui.DashboardActivity.onRequestPermissionsResult(DashboardActivity.java:71) 

    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6582) 

    at android.app.Activity.dispatchActivityResult(Activity.java:6460) 

    at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) 

    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 

    at android.app.ActivityThread.-wrap16(ActivityThread.java) 

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 

    at android.os.Handler.dispatchMessage(Handler.java:102) 

    at android.os.Looper.loop(Looper.java:148) 

    at android.app.ActivityThread.main(ActivityThread.java:5417) 

    at java.lang.reflect.Method.invoke(Native Method) 

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

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

    at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1489)

    at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1507)

    at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)

    at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)

    at com.mobility.ui.DashboardActivity.init_aroundBody0(DashboardActivity.java:65)

    at com.mobility.ui.DashboardActivity$AjcClosure1.run(DashboardActivity.java:1)

    at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)

    at com.canelmas.let.DelayedTasks$Task.call(DelayedTasks.java:66)

    at com.canelmas.let.DelayedTasks$Task.execute(DelayedTasks.java:59) 

    at com.canelmas.let.Let.handle(Let.java:72) 

    at com.mobility.ui.DashboardActivity.onRequestPermissionsResult(DashboardActivity.java:71) 

    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6582) 

    at android.app.Activity.dispatchActivityResult(Activity.java:6460) 

    at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) 

    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 

    at android.app.ActivityThread.-wrap16(ActivityThread.java) 

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 

    at android.os.Handler.dispatchMessage(Handler.java:102) 

    at android.os.Looper.loop(Looper.java:148) 

    at android.app.ActivityThread.main(ActivityThread.java:5417) 

    at java.lang.reflect.Method.invoke(Native Method) 

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

P.S. Thanks a ton for the library! 👍

Hey @izBasit , thanks for reporting!

I had doubt about the issue when I first read it, whether it's really related to "multiple permission request". After analyzing your stacktrace I believe you likely hit a known issue about support library fragments (android.support.v4):

https://code.google.com/p/android/issues/detail?id=190966

I'm assuming you're trying to commit a support.v4 fragment transaction, i.e. adding/replacing a fragment or prompt a dialog fragment on permission request result. You'll probably get the same error without let library, as long as your transaction is committed inside onRequestPermissionsResult().

Without knowing exact reason for this known issue, you may want to :

  • switch to native fragments (yeap, it doesn't happen with native fragments)
  • add a delay to your commit
  • use (carefully) commitAllowingStateLoss( )
  • modify your design/structure/approach

Let me know what you think.