Android viewpager fragmentmanager is already executing transactions

FragmentManager уже выполняет транзакции после использования метода setOffscreenPageLimit ()

У меня есть ящик для навигации с несколькими фрагментами, и один из них представляет собой tablayout с двумя фрагментами recyclerview, элементы RecyclerView исчезают после переключения между фрагментами ящика для навигации, я нашел решение, которое мне нужно использовать метод setOffscreenPageLimit () с ViewPager, но Это дает мне ошибку, указанную в заголовке вопроса

Вот мой логарифм

Это код фрагмента макета вкладки

Я столкнулся с подобной проблемой, как вы, после нескольких часов исследований, я нашел проблему. Если ваш ViewPager создан внутри Фрагмента, вам нужно использовать getChildFragmentManager () для FragmentPagerAdapter, а не getFragmentManager ().

Поэтому ваш метод setupViewPager () должен выглядеть так.

Основная причина проблемы заключается в том, что вы встроили фрагменты внутри фрагмента, поэтому он будет генерировать исключение.

Согласно документам Google:

Теперь вы можете вставлять фрагменты внутри фрагментов. Это полезно для различных ситуаций, в которых вы хотите разместить динамические и повторно используемые компоненты пользовательского интерфейса в компонент пользовательского интерфейса, который сам по себе является динамическим и может использоваться повторно. Например, если вы используете ViewPager для создания фрагментов, которые прокручиваются влево и вправо и потребляют большую часть пространства экрана, теперь вы можете вставлять фрагменты на каждую страницу фрагмента. Чтобы вставить фрагмент, просто вызовите getChildFragmentManager () на фрагменте, в который вы хотите добавить фрагмент. Это возвращает FragmentManager, который вы можете использовать, как обычно, из операции верхнего уровня для создания транзакций фрагментов.

Источник

Читайте также:  Wifi repeater для андроид

FragmentManager is already executing transactions #104

Comments

nkpodolyan commented Jun 27, 2019

Here is a stack trace:

»’
java.lang.IllegalStateException: FragmentManager is already executing transactions
at androidx.fragment.app.FragmentManagerImpl.ensureExecReady(FragmentManagerImpl.java:1659)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1720)
at androidx.fragment.app.FragmentManagerImpl.executePendingTransactions(FragmentManagerImpl.java:183)
at ru.terrakok.cicerone.android.support.SupportAppNavigator.applyCommands(SupportAppNavigator.java:44)
at ru.terrakok.cicerone.CommandBuffer.executeCommands(CommandBuffer.java:42)
at ru.terrakok.cicerone.CommandBuffer.setNavigator(CommandBuffer.java:25)
at my.app.MainFragment.onResume(MainFragment.kt:60)
at androidx.fragment.app.Fragment.performResume(Fragment.java:2644)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:921)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1237)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1302)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2075)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1865)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1820)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1726)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
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:858)
»’

This happens after I use cicerone navigator to replace fragments in activity (navigator uses support fragment manager). Inside target fragment (1) inside onViewCreated() callback I ask cicerone to add child fragment and (2) set navigator to cicerone navigation holder (navigator uses child fragment manager) inside onResume() callback.

CommandBuffer.setNavigator() causes executing pending transactions and application crashes with the provided exception.

Please advice how to overcome this issue

The text was updated successfully, but these errors were encountered:

Источник

FragmentManager is already executing transactions #20

Comments

ddpatel2606 commented Apr 21, 2017

I have used your code But I am getting error

«FragmentManager is already executing transactions»

infoWindowManager.onParentViewCreated(mapViewContainer, savedInstanceState);

this is my stack trace

java.lang.IllegalStateException: FragmentManager is already executing transactions
at android.support.v4.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:1956)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1980)
at android.support.v4.app.BackStackRecord.commitNow(BackStackRecord.java:620)
at com.appolica.interactiveinfowindow.InfoWindowManager.onParentViewCreated(InfoWindowManager.java:172)
at gtl.com.lotusrestrooms.fragments.MapLocatorFragment.onCreateView(MapLocatorFragment.java:237)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:763)
at gtl.com.lotusrestrooms.activities.TokenActivity.loadFragment(TokenActivity.java:328)
at gtl.com.lotusrestrooms.activities.TokenActivity$1$1.run(TokenActivity.java:198)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

The text was updated successfully, but these errors were encountered:

deangenovski commented Apr 21, 2017

Are you using the MapInfoWindowFragment or are you using the InfoWindowManager directly.

Are you by any chance adding other fragments to the same fragment manager that the InfoWindowManager is using?

At which point does this exception happen?

We will investigate this, meanwhile you can try changing: all commitNow calls in InfoWindowManager to commit .

It could really help us resolve this issue if you could answer the questions above.

We will keep you updated once we have discovered the problem.

Читайте также:  Топ idle rpg андроид

ddpatel2606 commented Apr 21, 2017 •

I have added MapView in my Fragment named as MapInfoWindowFragment

The Map loaded successfully working perfectly & all pins displayed on the map.

But when I click on any info-window & it is opened & trying to load the same fragment again at that time gets crashed.

Источник

FragmentManager is already executing transactions #214

Comments

alouanemed commented Mar 12, 2018

rxPermissions = new RxPermissions(this);

I don’t know exactly the reason behind this as it was working before without any issue.

The text was updated successfully, but these errors were encountered:

rogerou commented Jun 6, 2018

epool commented Jul 6, 2018

this should be fixed with #233

leodeleon22 commented Jul 10, 2018 •

I’m targeting API 27 and I also have this error if I request the permission onViewCreated on a Fragment. What’s the workaround? @epool

chetbox commented Jul 10, 2018

I have the same issue as @leodeleon22 using version 0.10.1.

I tried moving the initialisation to onStart but that gives same error.

epool commented Jul 10, 2018

@leodeleon22 @chetbox now when you instantiate new RxPermissions(this) from a fragment you have to pass the fragment instance instead of the fragment’s activity. This is fixed with v0.10.2

guness commented Dec 8, 2018

@leodeleon22 @chetbox now when you instantiate new RxPermissions(this) from a fragment you have to pass the fragment instance instead of the fragment’s activity. This is fixed with v0.10.2

mate this is bug itself. not the fix.

kirilamenski commented Feb 21, 2019 •

Has anyone found solution?

I solved this by running after delay:

but it is dirty hack

ronjdaugherty34 commented Apr 4, 2019 •

The dirty hack works I just added a second debounce to the chain

rxPermissions.requestEachCombined(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.CALL_PHONE, Manifest.permission.BLUETOOTH
)
.debounce(1, TimeUnit.SECONDS)
.subscribe < permission ->
when <
permission.granted -> <>
permission.shouldShowRequestPermissionRationale -> <>
else -> <>
>
>

moz1q1 commented Jan 16, 2020

GensaGames commented Jan 20, 2020

Any ideas, when this bug will be fixed? This is ridicules. You have inside method RxPermission, with could accept Activity, or Fragment. But for Activity it’s crashing.

mrArtCore commented Jan 20, 2020

@GensaGames This is not ridiculous. It’s been a long time since a saw the maintainer active in this repository.
Maybe because of such commentators? The community of this repository does nothing just create issues. And if this is the cause of why maintainer is inactive so long I can’t blame him. I understand.

Читайте также:  Как раздать вай фай с ноутбука для андроид

But!
Why don’t you fix this? Go and create PR, you are welcome!

GensaGames commented Jan 20, 2020

@mrArtCore I’m sorry for my message tone above.

mrArtCore commented Jan 20, 2020

@GensaGames
Nice to see your message above! Thanks! Take care !
And how about to fix it ? =))

relaxedSoul commented Aug 13, 2021

Any ideas, when this bug will be fixed? This is ridicules. You have inside method RxPermission, with could accept Activity, or Fragment. But for Activity it’s crashing.

To be honest, I am not sure there is actually a fix. It is the same as calling Activity.startActivityForResult inside Fragment and wait for result in Fragment.onActivityResult.

I mean, the only solution I see is creating annotations to say IDE to count it as a warning with the message.

Just use the right methods in the right places. For me, the fix is made and I use the right constructor in the right place.

Источник

Android viewpager fragmentmanager is already executing transactions

After login will go to this mainpage:

This is MainPage.Cs

public partial class MainPage : Shell < public MainPage() <

@LandLu said: Did you have some code about this issue? It seems you were trying to replace some fragments using FragmentTransaction . Did you execute this transaction on the main thread?

Could you please give some descriptions about how to reproduce the issue with the code you posted? FragmentManager is an Android native control. If you only use the shell to build the app, this error shouldn’t be there.

@LandLu ..when i click on login button ,will go to main page . At main page i created shell page which contain FlyoutItem .. Flyoutitem menu item contain LHSPage which is home page & other two setting & logout . when i click on setting will go to setting page..when i click on logout will back to first login page. But when i go to login again and click on logout i get that above error i.e FragmentManager is already executing transaction. how can resolve this

Источник

Оцените статью