Questions tagged [onsaveinstancestate]

230 questions
44
votes
6 answers

when is onRestoreInstanceState called?

Sorry for my incomprehension, but I am new in the android development. I have an application with activity A and activity B in it, and I go from activity A to activity B. When I left activity A, the onSaveInstanceState method was called, but when I…
44
votes
8 answers

Checking if state is saved before committing a FragmentTransaction

I sometimes see the following stacktrace for a commit that can happen when the user isn't looking at the activity (after state's been saved): java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at…
12
votes
1 answer

android:support:fragments saved by Activity is getting larger and causing TransactionTooLargeException

I have an Activity which controls several Fragments. The default Fragment is HomepageFragment. When replacing to a different Fragment i always make sure the stack stays flat - meaning only the HomepageFragment stays in the stack and on top of it the…
9
votes
2 answers

Restore fragment with two views having the same id

I have a complex layout to implement. It has 19 sections that can be displayed or not based on plenty of parameters previously entered by the user. In order to simplify the code and to not display unused sections, the layout is created…
Eselfar
  • 3,759
  • 3
  • 23
  • 43
8
votes
1 answer

Save state of fragment A when navigating from bottomNavigationView to fragment B

I am new to Android and I have been struggling for some time now with saving state of a fragment. My app has 5 options in the bottomNavigationView (I am using the default activity from Android). In fragment A (actually called "SearchFragment") I…
7
votes
1 answer

android - using same fragment for multiple activities

I want to use a fragment in multiple activities. In the first activity i will use it in, I created it by final ScoreBoard fragment = new ScoreBoard(); getFragmentManager() .beginTransaction() …
5
votes
1 answer

onSaveInstanceState called after onDestroyView

I'm dealing here with strange fragment lifecycle behavior. I have an activity that host two fragments: CityFragment - to display cities list and WeatherFragment - to display the weather forecast for selected city. When the app starts CityFragment is…
5
votes
4 answers

Can not perform this action after onSaveInstanceState show

I'm getting the following crash reports: Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1832) …
4
votes
2 answers

savedInstanceState is null after first app shutdown but not after second

I am following this codelab Android Kotlin Fundamentals 04.2: Complex lifecycle situations https://codelabs.developers.google.com/codelabs/kotlin-android-training-complex-lifecycle/index.html#4 In tast 5 you simulate app shutdown and use…
4
votes
1 answer

how to store recyclerview data on onSaveInstanceState

I want to save data from the API in the RecyclerView so that when rotating the screen is not reloaded I think I can use onSaveInstanceState but still don't really understand how to use it @Override public void onViewCreated(@NonNull View view,…
4
votes
0 answers

savedInstanceState in parent activity is null when up button in child activity is pressed

I have a problem with the usage of the Up button in my application. There are many posts that I already read dealing with similar problems, but none of them addresses the same issue that I want to solve. I have two activities - A and B. A displays…
castafiore
  • 81
  • 8
4
votes
0 answers

Android Espresso test save and restore instance state

I try to test Activity's instance state save and restore in Espresso. How to test the full life cycle? The suggest at How to test saving and restoring state of an android activity with Espresso? is helping already, but how can we test the…
4
votes
2 answers

How to examine the size of the Bundle object in onSaveInstanceState?

I am using Android Studio 3.0.1 which allows to inspect the Bundle object in onSaveInstanceState: @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } To do so add a breakpoint and once the…
JJD
  • 50,076
  • 60
  • 203
  • 339
4
votes
0 answers

how to find out what data the saveInstance is saving

got android.os.TransactionTooLargeException, it is said because of “This exception occurs when too much data is transferred via Parcels concurrently. The underlying Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared…
lannyf
  • 9,865
  • 12
  • 70
  • 152
4
votes
2 answers

Failure delivering result ResultInfo | java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

I have Simple app first I display MainActivity then after MainActivity became visible I display TransparentActivity after that onClick I kill TransparentActivity and I create and display dialog. During last step I get Error Error Failure delivering…
user7807288
1
2 3
15 16