android-lifecycle Questions

2

I'm trying to make floating cameraview for my screen recorder application. FloatingViewService.java public class FloatingViewService extends LifecycleService implements CameraXConfig.Provider, Life...

3

Solved

I get an java.lang.IllegalStateException: CompositionLocal LocalLifecycleOwner not present error when I collectAsState() or collectAsStateWithLifecycle(). I do not know what is wrong. This previous...
Merocrine asked 16/5, 2024 at 13:50

9

Solved

I need to automatically refresh an Android Compose screen when the app returns to the foreground. I have an that requires permissions and location services. If the user has switched any of these of...
Anson asked 9/3, 2021 at 12:33

4

I'm developing an app that integrates with Unity3d, in some part of my code I call an UnityPlayerActivity that starts the Unity3d code. When user finishes using the Unity3d he press a button and go...
Homerus asked 19/4, 2016 at 12:27

0

So I was trying to use androidx.lifecycle:lifecycle-runtime-compose to implement onStart/onStop events for my Composable screens: In MainScreen I have: LifecycleStartEffect(Unit) { Timber.d("...

3

Solved

In Jetpack Compose all screen are composable function. Fragments are not used in Jetpack Compose. How we can handle lifecycle events with Jetpack Compose? If we use Fragment we can handle lifecycle...

3

Solved

I'm using Jetpack Compose now. I realized I could have ViewModel per my composable and init view model in composable just like this: val myViewModel:MyViewModel = viewModel() But there is a proble...
Affricate asked 28/11, 2021 at 6:33

3

Solved

Is the AdView automatically tied to the activity life cycle or do you have to explicitly call the pause, resume, destroy events? Does it depend on the size of the AdView? I'm using banner ads. I co...
Serpentine asked 27/8, 2019 at 16:43

10

Solved

Hopefully someone can help me figure out, if not a solution, at least an explanation for a behaviour. The Problem: On some devices, pressing the launcher icon results in the current task being re...
Lipread asked 23/10, 2013 at 15:24

4

Solved

My launcher activity i.e. MainActivity is getting instantiated twice while using AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) which is leading to two network calls and ma...

9

Solved

Can you please explain which activity life cycle method is called when a dialog comes on the application? I'm confused whether its is calling onResume() or onPause() method. Thanks
Austerity asked 17/3, 2016 at 5:12

5

Solved

I'm investigating a weird issue, where we changed the androidx.appcompat:appcompat from 1.3.1 to 1.4.1 and all of a sudden our LifecycleObservers observing process lifecycle stopped emitting any ev...

16

Solved

FATAL EXCEPTION: main Process: com.example.loan, PID: 24169 java.lang.IllegalStateException: Fragment already added: FormFragment{428f10c8 #1 id=0x7f050055 form} at android.support.v4.app.Fragment...

5

Solved

I have been developing for Android for little less then 2 years, and I am still puzzled by this seemingly simple question. When should one implement a service? From my experience there are some rar...
Jural asked 15/1, 2014 at 21:35

2

Solved

Actually, I would say that both iOS ViewControllers and Android Activities have their lifecycle methods. For example an equivalent of ViewController.viewDidLoad() is Activity.onCreate() ? Else I s...
Lorient asked 10/3, 2015 at 16:27

4

1) I have an Activity. This Activity starts a service, which in turn creates and registers a BroadcastReceiver. 2) I have an Activity. This Activity creates and registers a BroadcastReceiver. Whe...
Attwood asked 5/1, 2014 at 16:21

1

I've a strange behavior with an android app when it runs on a S3 with android 4.3: every time app goes to background (pressing back button), when it's resumed, it calls the onCreate() method of App...
Uboat asked 26/6, 2014 at 17:58

1

Solved

I want to use Jetpack Compose to implement the floting window UI. But I got this error:java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from androidx.compose.ui.platform.ComposeVie...

1

Solved

In my Android project in AndroidStudio a class (named MyService below), which extends LifecycleService, is marked with the following error message: Class 'MyService' is not abstract and does not im...
Collateral asked 14/4, 2023 at 9:10

4

Solved

Whenever you call .observe() on LiveData, the Observer receives the last value of that LiveData. This may be useful in some cases, but not in mine. Whenever I call .observe(), I want the Observe...

4

First of all, I know how to create Handler. I am working on a project where I am using Handler with postDelayed. There are some times when app got crashed because activity was destroyed and the tas...
Hypnotist asked 12/1, 2021 at 12:1

4

Solved

Unfortunately I can't use getApplication() as LifecycleOwner, because android.app.Application does not seem to implement it. Why does android.app.Application not implement LifecycleOwner? Code wh...
Rawson asked 20/6, 2019 at 15:3

7

Solved

I am extending Application class to work with some global variables that need context. I know there is onCreate() method in the Application class that gets called before any other onCreate() in act...
Shalom asked 24/6, 2013 at 14:39

3

I have a UseCase and remote repository that return Flow in a loop and I collect the result of UseCase in the ViewModel like this: viewModelScope.launch { useCase.updatePeriodically().collect { res...
Bonzer asked 30/5, 2021 at 15:46

5

Solved

Google deprecate fragment’s onActivityCreated() on Android and recommend to use LifeCycleObserver: To get a callback specifically when a Fragment activity's * {@link Activity#onCreate(Bundle)} i...
Blackstock asked 19/4, 2020 at 15:15

© 2022 - 2025 — McMap. All rights reserved.