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

Collect from only between onResume and onPause Android

I have a HomeActivity with a TabLayout and 3 fragments. OneFragment, TwoFragment, ThreeFragment. In the HomeViewmodel i have a StateFlow which takes a value and OneFragment collects the result and then opens a Dialog popup. Custom flow class class…
james04
  • 1,580
  • 2
  • 20
  • 46
0
votes
2 answers

onActivityCreated() is deprecated and I think it's causing my save contact feature to not work, but no idea how to fix it

I have been working on an Android app for a project and have to make a communications button that basically just works as a contacts app. So I followed a tutorial on how to make it, but he uses some deprecated libraries, including a lot of…
0
votes
1 answer

Coroutine initializes one lateinit var but not the other

I am making two retrofit calls from lifecycle scope. These two calls use async and await to get data from api. Code : package com.example.retrofittodo import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import…
0
votes
1 answer

Jetpack Lifecycle: Fragment's View Lifecycle never reaching CREATED state, never destroyed

Problem I recently noticed one case when in an Android app, the following exception is triggered: java.lang.IllegalArgumentException: Cannot add the same observer with different lifecycles It happens when registering some Observer for a viewmodel's…
Vince
  • 1,570
  • 3
  • 27
  • 48
0
votes
1 answer

How can I define lifecycleaware coroutinescope for activity or application in composable function?

Let says I have splash Screen: @Composable fun SplashScreen(viewModel: SplashViewModel = hiltViewModel()) { val lifecycleOwner = LocalLifecycleOwner.current val externalsomeScope="?" …
0
votes
1 answer

Pressing back button in Android MainActivity does not destroy the activity anymore. Is it a new feature?

When I press the back button in MainActivity the home screen is shown, however onDestroy is not being called. Is it a new feature? Using Emulator Pixel 3A in API 33 arm 64-v8a. The same happens through the phone pixel 6A API 33. Also local variables…
0
votes
0 answers

Android app crashing after 3 rotations. JAVA/ANDROID

Im not sure what i could have done to make it consistently crash after 3 rotations. I was debugging and profiling the app while testing the crash and not once did the debug console tell me anything like a null pointer or something, it crashes…
Kooshe
  • 1
  • 1
0
votes
0 answers

Is AccessibilityService's lifecycle is more than Application's lifecycle?

Suppose I initialize Firebase AppCheck in the Application class onCreate method. Can I access it in AccessibilityService or it may get destroyed? Also, if it may get destroyed, where should I initialize it?
Jazib Khan
  • 408
  • 4
  • 13
0
votes
0 answers

Andorid click event triggers the backstack actitivty

I'm dealing with unexpected situation. There is an activity(Activity A) triggers another activity(Activity B). and Activity B triggers another Activity (Activity C). All activities are half screen transparent theme. The problem is when i click the…
0
votes
1 answer

Android java.lang.IllegalStateException: Method addObserver must be called on the main thread

In my recent app version, I am seeing a lot of logs related to this issue: java.lang.IllegalStateException: Method addObserver must be called on the main thread…
0
votes
0 answers

NDK Global value lifecycle

In Android NDK, I use an audio synth engine, which takes a few seconds to initialize. Therefore, I want to use a global (legitimate use of singleton) variable alive as long as possible. Are there any concerns regarding the Android app life-cycle, or…
Kirsteins
  • 27,065
  • 8
  • 76
  • 78
0
votes
0 answers

How to start a TextView Invisiable once the Lifecycle hits onResume

So I want to have this character count TextView start off Invisible whenever the Fragment comes into the foreground. I've tried a few ways but I think this code is really the one that's controlling what the view does Here's the Adapter class class…
OEThe11
  • 341
  • 2
  • 11
0
votes
0 answers

How to detect the exact moment when the app is killed?

I need to make an api call when the app is being killed but lifecycle callbacks are not called when the user just swipes up the app from recent tasks. I tried to check onPause, onStop, onDestroyed callbacks but none of them called when I killed the…
0
votes
1 answer

Launcher Activity's onStart() called before PendingIntent destination activity launched when Application is in Background State

I am showing notification when FCM message received in onMessageReceived. I am launching a intermediate UI less activity (PushTracker activity) to do preprocessing of the notification before navigating to destination activity. I have MainActivity as…
0
votes
1 answer

Flutter Widget Life Cycle Warning/Exception from Animation Widget

I am trying to build a simple Loader animation inside Flutter using custom animations making use of an Animation Controller and a Tween method. The animation works fine on the mobile, but I am getting an endless list of warning messages that…