Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Calling compose&subscribe within onActivityCreated in fragment leads to crash #140

Closed
MinkiPan-zz opened this issue Apr 18, 2017 · 5 comments

Comments

@MinkiPan-zz
Copy link

MinkiPan-zz commented Apr 18, 2017

onActivityCreated {
RxView.clicks(btn_fragment_permissions_camera)
				.compose(rxPermissions.ensure(Manifest.permission.CAMERA))
				.filter { it }
				.subscribe {
					Toast.makeText(activity, "Camera Permission granted", Toast.LENGTH_SHORT).show()
				} 
}

java.lang.IllegalStateException: Recursive entry to executePendingTransactions
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1550)
at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:563)
at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:54)
at com.tbruyelle.rxpermissions2.RxPermissions.(RxPermissions.java:41)
at com.example.mingkangpan.learnrx2.fragment.PermissionFragment$rxPermissions$2.invoke(PermissionFragment.kt:21)
at com.example.mingkangpan.learnrx2.fragment.PermissionFragment$rxPermissions$2.invoke(PermissionFragment.kt:19)
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
at com.example.mingkangpan.learnrx2.fragment.PermissionFragment.getRxPermissions(PermissionFragment.kt:0)
at com.example.mingkangpan.learnrx2.fragment.PermissionFragment.init(PermissionFragment.kt:35)
at com.example.mingkangpan.learnrx2.fragment.PermissionFragment.onActivityCreated(PermissionFragment.kt:30)
at android.app.Fragment.performActivityCreated(Fragment.java:2361)

when I use rxpermissions in fragment, I cant use it in onActivity create, seems like the fragment manager is in same state while onActivityCreated, which doesn't allow another fragment to be attached

@tbruyelle
Copy link
Owner

Fragments are really a plague !

@MinkiPan-zz
Copy link
Author

do you think this is somehow fixable? meanwhile I have to post delay the method call

@tbruyelle
Copy link
Owner

Sorry I have no idea, community pushed me to use fragments for this lib (originally it was an Activity), and I finally accepted but I regret. I don't use fragment from ages, so sorry I can't help you.

@epool
Copy link
Collaborator

epool commented Apr 26, 2017

@MinkiPan could you please share us a project example to reproduce this error? I have tried to reproduce it but I wasn't lucky, I was able to request permissions inside of a fragment in the onActivityCreated method.

@MinkiPan-zz
Copy link
Author

MinkiPan-zz commented May 4, 2017

@epool

okay it doesn't crash with support fragment/manager
seems like the rumours are right that support fragment are less buggy than fragment....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants