Questions tagged [onrestoreinstancestate]

88 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…
42
votes
8 answers

How to simulate killing activity to conserve memory?

Android doc say: "When the system, rather than the user, shuts down an activity to conserve memory, ... " But how to simulate this situation?I want to debug the onRestoreInstanceState(Bundle) method,but don't know how to.
L.J.W
  • 1,575
  • 5
  • 18
  • 24
18
votes
2 answers

Should I restore savedinstancestate in onCreate or in onRestoreInstanceState?

I have an activity that starts some other activities for results, so when the result comes back, the activity may or may not have been destroyed and recreated. I have overridden onSaveInstanceState so as to add the data that needs to be preserved…
matteo
  • 2,934
  • 7
  • 44
  • 59
13
votes
5 answers

When to use getSharedPreferences vs savedInstanceState?

I'm trying to figure out when to use a saved instance state versus loading information from a shared preferences file. I have two variables that I wish to save, time and score. I want to make sure that if the user returns to the game screen that…
11
votes
1 answer

Fragments restore state on orientation changed

I have to implement "standart" fragments navigation in my app (please see link). The issue is when device is in portrait mode, there should be shown only 1 fragment, and when it is rotated to landscape mode, 2 fragments should be shown. I tried to…
6
votes
1 answer

Android activity lifecycle

What is called first when activity is restored? onRestoreInstanceState or onActivityResult?
6
votes
1 answer

What to pass in Android Dialog fragment show() method's TAG parameter

Hope you are doing well. I created a dialog fragment and called show() on the instance. I passed a custom tag to show()'s parameter. The fragment requires no other arguments. On config change, resizing the window of the app, the app crashes. …
4
votes
0 answers

onRestoreInstanceState never called for custom views created dynamically

I am very new to Android (coming from iOS background). I have created a custom/compound view that is simply five buttons inside a merge tagline: