Questions tagged [onsaveinstancestate]
230 questions
3
votes
2 answers
save Instance State in Android studio: Kotlin
I was doing this program and tried to run an app as an output. However, when I turned the app in Landscape mode, my text output didn't work. I realized that I need to add onSaveInstanceState in the Kotlin code, which I don't know how to…

ibrahim shaffee
- 55
- 1
- 1
- 5
3
votes
0 answers
Why onSaveInstanceState() is NOT needed in my situation?
being a beginner in Android, I learned that when we turn our phone, the activity is destroyed and recreated, hence the interest to save the values of the fields so as not to lose them during a rotation.
My "problem" is that, wanting to create a very…

Quentin
- 486
- 4
- 20
3
votes
1 answer
TransactionTooLargeException when onSaveInstanceState called
It Seems happened when onSaveInstanceState called.
Both Android 8.1 and 9.0 deveices have this problem.
How to solves this?
Thanks a lot!
13404-10 02:49:44.606 16580 16580 E JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size =…

user1665375
- 159
- 8
3
votes
3 answers
Should we use savedInstanceState in fragments if there are getArguments()?
In Android fragments we can get initial data in onCreate() from savedInstanceState or getArguments(). I often check them both for null and then assign variables. For instance, in Kotlin:
val bundle = savedInstanceState ?: arguments
bundle?.let {
…

CoolMind
- 26,736
- 15
- 188
- 224
3
votes
1 answer
Where use onSaveInstanceState and onRestoreInstanceState methods?
This is a conceptual issue. Sorry if it is a simple question, I start to learn Android few days ago.
I was trying to save the state of a recyclerview when the user out of the activity. And I read some articles about this.
In this article…

romeuBraga
- 2,135
- 1
- 8
- 20
3
votes
0 answers
Android: TransactionTooLargeException but bundle size is just 368
Finally, I was able to replicate TransactionTooLargeException in my app
I use FragmentStatePagerAdapter to show few fragments, Each fragment hosts a RecycleView and on click of each Item another fragment is being added.
On pressing Home button in…

Sourabh Saldi
- 3,567
- 6
- 34
- 57
3
votes
2 answers
Save state when navigating between fragments
I'm working on an app and I have a menu with a NavigationDrawer to navigate between fragments. In one of the fragments I make a call to the backend and then save the results in a list. When I navigate to another fragment and back, the results are…

Dennis van Opstal
- 1,294
- 1
- 22
- 44
3
votes
1 answer
How can I keep my RecyclerView after android rotation?
When I rotate my device, my activity instance is destroyed which starts a new onCreate. I can't figure out how to repopulate my RecyclerView after screen orientation. I have tried some solutions involing AndroidManifest:…

MOTIVECODEX
- 2,624
- 14
- 43
- 78
3
votes
2 answers
Saving RecyclerView list State
I have a recyclerView containing list of a objects of a class. Currently when I close my app all the list in the recyclerView gets lost and after restarting the app, recyclerView shows nothing(no list).
What and How shall I use to retain the list…

Gaurav Singh
- 125
- 3
- 12
3
votes
2 answers
implementing Parcelable in a derived-graphic class for onSaveInstanceState(Bundle)
I want to save and restore some data for screen orientation changes (portrait/landscape).
For doing it, I implemented onSaveInstanceState and onRestoreInstanceState in my class that holds the list that I want to restore. It seems to be working, and…

Maor Cohen
- 936
- 2
- 18
- 33
3
votes
1 answer
Android: RecyclerView GridLayoutManager - Restoring scroll position doesn't work properly
I have 3 activities:
A --> B --> C
In Activity B, I'm populating using RecyclerView's GridlayoutManager. I want to save the scrolled state when i navigate to Activity C and restore the scrolled state when i go back to Activity B from Activity…

Zayid Mohammed
- 2,275
- 2
- 10
- 17
3
votes
3 answers
Android java.lang.IllegalStateException in onRequestPermissionsResult()
I am working with sd card and so trying to get permission in runtime. Here is the code:
public class MainActivity extends AppCompatActivity implements FileListFragment.OnFragmentInteractionListener {
private static final int…

dev_android
- 8,698
- 22
- 91
- 148
2
votes
1 answer
What is "androidx.lifecycle.BundlableSavedStateRegistry.key" in this bundle?
I'm using toolargetool to investigate why the app is crashing from TransactionTooLargeException.
I'm seeing there's this key androidx.lifecycle.BundlableSavedStateRegistry.key which can be around 400 KB when I put the app into the background.
What…

SmallGrammer
- 893
- 9
- 19
2
votes
1 answer
How to save and restore recyclerview position in fragment
Hello I want to save the position of the recycler view when navigating from one fragment to another and then restore the scroll position when returning to the fragment
Note
I didn't try any method till now because I don't know where exactly I
have…
user15537898
2
votes
1 answer
IllegalStateException Can not perform this action after onSaveInstanceState show DialogFragment
This is the very first time I ever encounter this problem.
I already took a long look to the several answers on SO, especially this one and this one but it didn't solve my problem and most of the answers can't be used as a safe and robust way to…

Itoun
- 3,713
- 5
- 27
- 47