Questions tagged [android-lifecycle]

Questions regarding the events forwarded by the system to components, during their lifetime, in an Android Application. Most components have a specific LifeCycle that is imposed upon them. This tag is not meant to be used alone: use with the [android-activity], [android-service] and [android-broadcastreceiver] tags.

Questions regarding the events forwarded by the system to components, during their lifetime, in an Android Application. Most components have a specific LifeCycle that is imposed upon them. This tag is not meant to be used alone: use with , , , or

Android Activity Lifecycle

Activity and Fragment Lifecycle Diagram

2414 questions
0
votes
0 answers

In .net Maui android I need when airplane mode change toast a message on app

This is my code in MauiProgram.cs but when I change airplane Mode nothing happens and 'OnReceive' is not called, is there any suggestion? this is my first app on Maui and I am not familiar with it In .net Maui android I need when airplane mode…
Navid
  • 609
  • 6
  • 6
0
votes
0 answers

Why is my App home screen/landing screen zoomed in when resuming application from background - Android

My app screen in which I minimized/backgrounded the app appears zoomed in when I resume the app from the background after about 15-20 minutes. This is primarily observed in Samsung, Oppo & Vivo phones
0
votes
1 answer

Different between Android onResume(), onStart() and lifecycleScope

I have viewmodel call TestViewModel and a method call fetchDataFromDataSource() to call fetch data from the server, I used to call load data on OnResume() until I bump into lifecycleScope I have tried to read more but didn't really get which is…
Muraino
  • 554
  • 7
  • 18
0
votes
0 answers

ViewModel unexpected onCleared() call

I have a viewpager with 10+ pages in it, each page corresponds to its PageFragment and PageViewModel instances. When I start to swipe fragments one after another the onCleared() method is called for viewmodel that was left behind 2-3 steps ago, for…
0
votes
1 answer

Why user input isn't restored via onRestoreInstanceState on Android 10?

I have this following code: public class MainActivity extends AppCompatActivity { EditText edtInput; private static final String STATE_RESULT = "state_result"; @Override protected void onCreate(Bundle savedInstanceState) { …
anta40
  • 6,511
  • 7
  • 46
  • 73
0
votes
1 answer

MutableLiveData triggered twice? Android

I am using from MutableLiveData for connect to API, for first time it work true but for second time call twice.(my observe call twice) Here is my Fragment: override fun onCreateView( inflater: LayoutInflater, container:…
jo jo
  • 1,758
  • 3
  • 20
  • 34
0
votes
0 answers

LiveData not giving callback on lifecycleOwner state change to active state

LiveData used to give callback when lifecycleOwner changed from inactive to active state, therefore we have SingleLiveEvent or Event wrapper as described in this article. But I am not getting callback on state change if callback was given once, I…
Parth Gupta
  • 69
  • 1
  • 5
0
votes
0 answers

How to make API call when returning to a fragment in the backstack

I have the following architecture: Fragment A shows a value from an API Call, Fragment B lets the user change the value using an API Call and user can tap a button to travel from A -> B. However when the user changes the value in B and presses back,…
Alex Petev
  • 501
  • 5
  • 19
0
votes
0 answers

How to do lifecycle aware communication between activity and fragment

Currently, I am using an interface to communicate from fragment to activity. I want to pass updated model back to the activity on onDestroyView to update UI but that is causing crash when activity is destroyed by system or we enable "don't keep…
Parth Gupta
  • 69
  • 1
  • 5
0
votes
0 answers

Android: Problem showing an empty view or data on a recyclerview (probably because of lifecycle)

I am working on an android app using Kotlin that lets a user record details about a vehicle then a list of saved vehicles is shown in a RecyclerView on the home screen. When there are no saved vehicles an empty view with a message is shown. I have…
0
votes
2 answers

What are the reasons behind the change in the order of onSaveInstanceState and onStop for APIs 28+?

After API 28 the order of execution of onSaveInstanceState() and onStop() is changed. Referring to this paragraph from the documentation: The reason for that change is the ability to firstly execute fragment transactions and then save state.…
Todor Kostov
  • 1,789
  • 1
  • 13
  • 20
0
votes
1 answer

How can I detect If my android application is Destroyed/Paused/Stopped without fail?

I want to update user activity status (Online/Offline) based on Application is running or not. To do so I have used LifecycleEventObserver to Observe the lifecycle inside the Application file. @Override public void onStateChanged(@NonNull…
0
votes
1 answer

Recycler View doesn't update with livedata.observe()

I have a BluetoothService Class which offers BLE Services like scanning and holding a MutableList of known devices. When scanning it adds new devices to the list and posts them with the postValue() function to notify about the change. My goal is to…
0
votes
0 answers

how to reset navigation onNewIntent

I have a share fragment receives a youtube share URL via intent and uses navigation the flow is: ScanFragment -> PlaylistFragment -> VideoFragment So the scan fragment parses the url and loads the data and then forwards to the relevant…
siliconeagle
  • 7,379
  • 3
  • 29
  • 41
0
votes
1 answer

Cannot resolve constructor ViewModelProvider(... .FragmentActivity, ... .ui.viewmodels.profileViewModelFactory)

I'm getting the following error when I hover over the red squiggly line where I'm passing in a custom ViewModelFactory into my ViewModelProvider: Cannot resolve constructor ViewModelProvider(androidx.fragment.app.FragmentActivity,…