Questions tagged [android-savedstate]

For questions related to Android's onSaveInstanceState and onRestoreInstanceState methods.

197 questions
2
votes
2 answers

How can I access "androidx.savedstate.ViewTreeSavedStateRegistryOwner" in Jetpack Compose 1.2.0?

I was able to access the below when I'm in Jetpack Compose 1.1.1 import androidx.savedstate.ViewTreeSavedStateRegistryOwner However, when switching over to Jetpack Compose 1.2.0, I can no longer access it. It errors out stating Unresolved…
Elye
  • 53,639
  • 54
  • 212
  • 474
2
votes
1 answer
2
votes
1 answer

How to save the state of delayed posts in Kotlin

For an Android app I have some content that I want to show with a delay. Therefore I'm using a handler. private lateinit var mHandler: Handler override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) …
Vadim
  • 51
  • 11
2
votes
2 answers

Restore RecyclerView's scroll position after performing Fragment replace()

I have a simple activity with two fragment: main (contains a list of items) and detail. Details screen is a fragment, which is displayed when an item is clicked in main list. DetailFragment is being shown using replace(). After navigating back from…
2
votes
1 answer

Is a fragment's savedInstanceState shared with the parent activity's savedInstanceState?

Fairly straightforward question but I am unable to find a clear answer anywhere. Is the savedInstanceState of a fragment the same object as the savedInstanceState of the fragment's parent activity (or encapsulating fragment)? If so, do I have to…
2
votes
1 answer

Fragment's bundle is null in onCreate despite overriding onSaveInstanceState

My MainActivity uses Fragments, a simplified version of the layout looks like this:
2
votes
3 answers

What is the second parameter in savedInstanceState.getInt?

I'd like to understand something from the following Android fragment docs: Android fragment docs In the example at the end of the page, the mCurCheckPosition int is saved in a bundle as "curChoice": @Override public void…
Christopher Mills
  • 711
  • 10
  • 28
2
votes
2 answers

Passing String from Activity back to running Fragment in Android

There are a few posts about similar problems but I just don't get the wright answers and I hope that anyone can help me. Situation: I have a MainActivity that contains several Fragments. In one Fragment I start a CameraActivity with an intent. When…
2
votes
1 answer

How to Save Application Class state

I have a class that extends Application class Here is My Application class public class UILApplication extends Application { public int count_group; public LoginUserInfo loginUserInfo = new LoginUserInfo(); public static ArrayList
Android
  • 1,085
  • 4
  • 13
  • 28
2
votes
0 answers

Why background drawable retain its state after activity finished?

I have a custom ViewGroup, It does only one thing, changing background's alpha on layout phase: @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { ... getBackground().setAlpha(0); ... } print…
DouO
  • 4,914
  • 1
  • 20
  • 29
1
vote
2 answers

Fragment onSaveInstanceState() called after onDestroyView()

The application started to receive some crashes (it is not reproducible 100%) due to some lifecycle issue for the Fragment. I'm using view binding and I'm manually invalidating the binding as per Android recommendations to avoid high memory usage in…
1
vote
0 answers

How to save instance of recyclerView after a drag and drop

I want to save the state of recyclerView after the drag and drop is there any way so far I have tried everything like sharedPreference,savedInstance etc.. is there any way to solve this issue. What I want is when I close the app and reopen it the…
1
vote
0 answers

How to store fragment state in activity android Kotlin

Hey I am working on androidx fragment. I want to ask is there any way to restore state of fragment in middle of language change configuration. For example I have 1 activity and 4 fragments. Activity 1st Fragment > 2 Fragment > 3 Fragment > 4…
Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127
1
vote
1 answer

Paging 3 RemoteMediator and SavedStateHandle

I'm using the RemoteMediator in an app to load page keyed data. Everything works fine, except when after process death, the data is refreshed. My current implementation is : val results = savedStateHandle.get("query").flatMapLatest { query…
Mihirrai
  • 205
  • 2
  • 5
1
vote
0 answers

Adding view dynamically in fragment not persist after moving back from another fragment through navigation

I'm adding view dynamically in fragment which works fine but when I'm navigating to another fragment and return back to first fragment all layout is set as initial one (dynamically added view is not present). So here I have to save UI state untill…
1 2
3
13 14