-
Notifications
You must be signed in to change notification settings - Fork 1.3k
W/System.err: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState #249
Comments
A lot of my app users have same problem and I don't know what to do... |
Maybe it's better to call |
问题解决了吗?我也遇到这个问题了 |
I still use version 0.9.5 ,in this version, there is no this issue. |
Thanks, I let't delay 200 millisecond, then no problem, if has problem I'm attempt your method! |
我fork了一份解决了这个问题,比楼上的延时处理更好 |
好像没有0.9.5 这个版本的吧 |
你是处理的哪里 |
fragment 创建时机问题,java.lang.IllegalStateException |
Same problem here |
i have this problem too |
i have problem too |
A detailed description of the problem and what you have to do is here.
we have to do:
|
@tim4dev disagree with your suggestions (but not with article). According to provided link
Good way of handling such situations will be dispose subscribtions to any We use a lot of Rx code in our projects and we've forgotten about described crashes since we started clear all related to screen subscribtions in |
@mrArtCore it's very good that you learned how to work with RxJava. But you can believe that none of us use calls after onSaveInstanceState, and yet the error appears. What exactly do you suggest? |
@tim4dev Hey, I don't like your sarcasm.
Show only stacktrace - is nothing. It's very hard understand what's going on if you will be look for problem solving without viewing from different perspectives. This is an open source project, remember ? Nobody get paid for that fix. And if you are interested in this fix - give some help, please. Describe problem correctly! |
so,will you change commitNow() to commitAllowingStateLoss()? |
Same problem. It is hard to reproduce and seems like a random error. |
Show us your code. Thats all. Oh, and stacktrace. And example project will be super helpful |
@mrArtCore This is one of the crash logs from Crashlytics.
|
Hi @stargt ! I see you have some testapp and just may be you are able to reproduce this crash ? |
I meet the same Exception |
@wangjiangtao Read carefully please, and if this is doesn't solve your problems, give us yout code example. |
老哥,,,你的pull request 未被允许呀 |
我也是 不提供解决方案吗 |
0.10.2 still have this problem |
This bug is also occasionally found on our side. |
@zhuxiaohao @lkang08 |
I don't know what to do with rx methods and I can't create example that can reproduce this exception (I've spend whole evening in tryings and can't reproduce). But exception in rx methods will be emitted into downstream and easy to catch. More important that this exception can be thrown with |
@fAntel Your activity/fragment is not in 'right' state, I suppose. Maybe it happens when screen is rotated or something. |
@mrArtCore if we look at stack traces above we can see this line |
@fAntel Thanks for suggestion. Still trying to stick to the library. But don't understand why, for calling three functions, which already implemented in AppCompat. |
Wow |
在 activity 的oncreate的时候就先使用rxpermission 把RxPermissionsFragment 的实例初始化并与当前activity相绑定就行,因为在RxPermissions的getRxPermissionsFragment中会做判断,判断该RxPermissionsFragment是否被初始化 |
You can use |
@mrArtCore Sorry for trouble you, but please check my case:
My problem is when loading API -> user move app to background -> RxPermission called on background -> so crash happened! So what should I do? Should I check if app is background and wait until app resume, then call RxPermisson? |
Can not perform this action after onSaveInstanceState com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment |
how to solve it? |
have you solved it? |
RxPermissions Class constructor creates a fragment; The onSaveInstanceState method is called right before the onStop method. If a fragment transaction is committed after onSaveInstanceState, Solution:
Alternatively, we can use a boolean to keep track of activity lifecycles if the androidx.lifecycle library is not added in your project!
|
Try unsubscribe from the stream whenever the state is saved -> |
09-15 13:31:03.381 15829-15829/com.doubtnutapp W/System.err: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2091)
at androidx.fragment.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:2229)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2249)
at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:648)
09-15 13:31:03.382 15829-15829/com.doubtnutapp W/System.err: at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:77)
at com.tbruyelle.rxpermissions2.RxPermissions.access$000(RxPermissions.java:36)
at com.tbruyelle.rxpermissions2.RxPermissions$1.get(RxPermissions.java:61)
at com.tbruyelle.rxpermissions2.RxPermissions$1.get(RxPermissions.java:54)
at com.tbruyelle.rxpermissions2.RxPermissions.pending(RxPermissions.java:211)
at com.tbruyelle.rxpermissions2.RxPermissions.request(RxPermissions.java:200)
at com.tbruyelle.rxpermissions2.RxPermissions.access$100(RxPermissions.java:36)
at com.tbruyelle.rxpermissions2.RxPermissions$2.apply(RxPermissions.java:102)
at io.reactivex.Observable.compose(Observable.java:6283)
at com.tbruyelle.rxpermissions2.RxPermissions.request(RxPermissions.java:176)
at com.doubtnutapp.ui.splash.SplashActivity.requestPermission(SplashActivity.kt:143)
at com.doubtnutapp.ui.splash.SplashActivity$onStart$1.onInitFinished(SplashActivity.kt:131)
at io.branch.referral.ServerRequestRegisterInstall.onRequestSucceeded(ServerRequestRegisterInstall.java:106)
at io.branch.referral.Branch$BranchPostTask.onPostExecute(Branch.java:2937)
at io.branch.referral.Branch$BranchPostTask.onPostExecute(Branch.java:2799)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6365)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
The text was updated successfully, but these errors were encountered: