Questions tagged [viewmodel-savedstate]
38 questions
1
vote
1 answer
How can we combine SavedStateHandler with LiveData Coroutine Builder?
In a typical Android ViewModel, we can easily create a Restorable LiveData using
val liveData = savedStateHandle.getLiveData("SomeKey")
Whenever the liveData value is set, it is automatically saved and restorable
However, if we use the…

Elye
- 53,639
- 54
- 212
- 474
1
vote
1 answer
How to create a non-nullable LiveData that can save state
When we have a liveData as below, we cannot _liveData.value++, as the value is nullable.
class MainViewModel(savedStateHandle: SavedStateHandle): ViewModel() {
private val _liveData: MutableLiveData =
…

Elye
- 53,639
- 54
- 212
- 474
1
vote
0 answers
Where and how is SavedStateHandle data stored on disk?
When saving part of the UI state using SavedStateHandle, the data in the state is persisted (on disk) on app process death. For various domain/business reasons, this data might contain sensitive information. Where and how is this data persisted? And…

Erik
- 4,305
- 3
- 36
- 54
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…

HEET PATEL
- 11
- 1
1
vote
1 answer
Android ViewModel with SavedState rewrites arguments for new instances
I have an app which is having Master/Detail kind of architecture. When I select some item, the details are displayed in details fragment.
For the detail fragment to know what to load id is sent over via Arguments. Using SavedStateHandle in VM I can…

bio007
- 893
- 11
- 20
1
vote
1 answer
SavedState module Android Kotlin with View Model - value does not seem to save
I have followed the instructions in Google Codelab about the Saved state module.
My gradle dependency is:
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc03"
My View Model factory is:
class MyViewModelFactory(val…

Rowan Gontier
- 821
- 9
- 14
1
vote
1 answer
2 way Databinding with ViewModel-SavedState
I have a subscription form: Name, Address, Local, etc, etc... and I want to be able to use Data Binding, LiveData and SavedStateHandle to handle and persist data.
Let's assume: 1 way Data Binding, LiveData and SavedStateHandle
private val _name:…

GuilhE
- 11,591
- 16
- 75
- 116
0
votes
1 answer
How to create 1 viewmodel with savedstatehandle for multiple chips?
I am trying to understand SavedstateHandle and how I can create 1 viewModel that can store multiple Chips using savedstatehandle. At the moment, whenever the user launches an onClickEvent on one of the chips, all the remaining chips get activated as…

Josef M
- 412
- 2
- 5
- 20
0
votes
0 answers
savedStateHandle only have args which is defined in navigation graph
Dependency
androidx.navigation:navigation-fragment-ktx:1.5.5
Fragment
override val viewModel by viewModels {
SavedStateViewModelFactory(
requireActivity().application, this,
bundleOf("groupId"…

Jayesh
- 101
- 6
0
votes
1 answer
How to change the model parameter saving location when training with DefaultTrainer in detectron2
my code is like following:
cfg = get_cfg()
...
trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()
After training, the model is automatically saved in./output/model_final.pth. I found the folder where the model is…
0
votes
1 answer
Re-setting learning rate while training in Pytorch
I am training a model using Learning Rate Scheduler in Pytorch to decrease the value of learning rate. By using learning rate scheduler, I reduced learning rate from 0.0001 to 1e-5, and save all the weights, parameters, learning rate values, etc at…

killermama98
- 45
- 5
0
votes
1 answer
How to benefit on "warm start" from the saved instance state bundle passed into onCreate() or onRestoreInstanceState()
After reading these Android documents, we feel confused about how to benefit on "warm start issue" from the saved instance state bundle passed into onCreate() or onRestoreInstanceState(().
In the document of saving-states, it says the "Saved…

Fisher
- 488
- 7
- 24
0
votes
1 answer
Configuration Changes Not Save App State MVVM
I am building a movie app. There is a recyclerview matching parent size,and 1 search action button(SearchView).
When I search for a movie,everything is working fine,but when I change orientation,the activity just lose it's state. the recyclerview…

HoLoGram
- 167
- 10
0
votes
1 answer
SavedStateViewModelFactory with Hilt
How to use SavedStateViewModelFactory with hilt initialization ?
I read about savedstate and all the developers initialize it without hilt And when I'm trying to initialize it with hilt like this :
private val imagePickerViewModel:…

Ahmed Mamdouh
- 83
- 7
0
votes
0 answers
Screen empty after rotation
I need to handle screen rotation so I read about saved state and I tried to implement it bit I cant !
here is the fragment screen :
@AndroidEntryPoint
class ImagePickerFragment : Fragment() {
private lateinit var imagePickerBinding:…

Ahmed Mamdouh
- 83
- 7