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
1 answer

What would happen to Activity's properties when the onDestroy call?

Two types of scenarios might happen when the onDestroy method calls! One is when config change occurs and another one is when the activity is finishing. Assuming we have an Activity with some properties. What would happen to these properties in…
0
votes
0 answers

Activity and it's start fragment are being created twice, triggering extra database queries. (Jetpack/Kotlin/Android)

I'm using databinding, the Jetpack Navigation Component (in which one activity hosts several fragments) and a shared ViewModel with activityViewModels() in the fragments. The Room database is initialized (and some resource expensive queries) when a…
0
votes
2 answers

Why is (and how to fix) my Android application triggering an onCreate (ON_CREATE) when removed from memory?

I manage an Android app for a client and am trying to detect when the app is removed from memory. I've noticed via logcat that when the app is removed from memory an ON_CREATE Lifecycle.Event is being sent. I do get an ON_STOP when the app is…
0
votes
0 answers

How to change the Activity when app is moved to background and then again when it is resumed?

my goal is to make my Password Manager app's current visible activity (e.g. MainMenuActivity) change to EmptyScreenActivity when app is paused (so nobody can see the passwords when the app is in background) and then run LoginScreenActivity when the…
0
votes
1 answer

Shares of Lifecycle Livedata ViewModel with ViewBinding

I'm still new to Kotlin. So I want to try Lifecycle, LiveData, and ViewModel in my study project, using moviedb as its data. But since Android Kotlin Extensions dependency is deprecated, I have to use viewBinding as an alternative, but when I run…
0
votes
1 answer

How do I create a root launcher Activity in an app, when onCreate() is not called on Android 12, API 31?

I want to create an Android app which has a specific Activity that acts as a 'Root Launcher Activity', to sometimes launch other Activities in the app. When this Root Launcher Activity starts, it will check a preference to see if it can directly…
Mr-IDE
  • 7,051
  • 1
  • 53
  • 59
0
votes
1 answer

In android lifecycle, is there any unique method gets called when app is swiped from recent app list?

In android lifecycle, is there any unique method that gets called when the app is swiped from the recent app list? We initially thought we would use onDestroy but it gets called during other activities as well.
0
votes
0 answers

Local variable not restored on orientation change for fragments in backstack

I have two fragments, FragmentA and FragmentB, the user can go from FragmentA to FragmentB Let's say FragmentA has a local variable varA. When the user is on FragmentA and changes orientation I can save that variable with onSaveInstanceState and…
Eratia
  • 1
0
votes
3 answers

How I can do a RecyclerView with MVVM

I am trying to do a recyclerView with mvvm, but I get empty recyclerView as a result any help please! the kt file : typeRecy = itemView.findViewById(R.id.typeRecy) typeRecy.layoutManager = LinearLayoutManager(context,…
0
votes
0 answers

RecyclerView, LiveData, Lifecycle dependencies

Hello kind people of the internet. My name is Paul. I've started to learn Android development using Kotlin, lately I've been following a couple of tutorials regarding RecyclerView, LiveData and Lifecycle. At first I honestly forgot to declare the…
0
votes
1 answer

Run Multi lifecycleScope on Fragment

I have a Home Fragment, and inside thatonCreateView fragment, I have 2 function, that will execute lifecycleScope. The first lifecycleScope will used to get all the list of cashFlow, and the second lifecycleScope will use to get all the total of…
0
votes
1 answer

LifecycleOwner also if I change Activity

I m trying to build a code to get position of the smartphone from a private SDK. So i m build this code: nextomePhoenixSdk.getLocalizationLiveData().observe((LifecycleOwner) myActivity, new androidx.lifecycle.Observer(){ public void…
bircastri
  • 2,169
  • 13
  • 50
  • 119
0
votes
1 answer

lifecycle between Parent Fragment and Child Fragment

All the Fragment inherits from BaseFragment. And I'd like to give back press event respectively to each fragment. But BaseFragment has default back press event like this. override fun onResume() { super.onResume() …
c-an
  • 3,543
  • 5
  • 35
  • 82
0
votes
1 answer

After update to androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' get error Method addObserver must be called on the main thread

After update androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' a got error Method addObserver must be called on the main thread.This error i got then i try to use: viewLifecycleOwner.lifecycleScope.launch { val userId =…
fXs
  • 1
  • 1
0
votes
3 answers

How to avoid recreating activity when the screen has rotated?

I use single Activity pattern in my app using Navigation component. I use YouTube Android library for playing the video. When I click full screen icon on video player the top and bottom tool bars have to be gone and the screen has to be changed on…
Artem
  • 93
  • 1
  • 6