2,441 questions
1
vote
0
answers
65
views
Can I leave in onBackPressed() method call in my Android activity for future Android 36+ versions?
Issue:
I've been updating my apps for the Android 36 updates. I've implemented the onBackPressedCallback for my activities. I've tried adding a DrawerListener that will set the DrawerLayout's ...
0
votes
0
answers
38
views
The dialog from DialogFragment appears twice
I have one activity called TourMapActivity and StopChoiceDialogFragment.
This is a map route type app. When the user starts the route, this modal opens. If the user clicks on any of the options, when ...
0
votes
1
answer
65
views
Why does Android ExoPlayer get started twice when my activity is re-launched after an in-app update?
When my Compose-based launch activity is run, it displays a video using ExoPlayer. This works fine, but when it happens after an in-app update the video starts playing briefly then restarts from the ...
0
votes
1
answer
69
views
Is it possible to bind and unbind a bound service via button click in Android?
Can I safely perform bindService() and unbindService() when a button is clicked inside an Activity or Fragment, instead of binding in onStart() and unbinding in onStop()?
Will it cause any issue if ...
0
votes
0
answers
55
views
Safe way to call findNavController.navigate/popBackStack during detached state
We recently got an exception where a findNavController.navigate() call was made from a fragment that seems to have been in the process of being destroyed, while another (the new/top one) was being ...
0
votes
0
answers
47
views
When using Voyager, Configuration Changes create problems with lifecycle handling. Demo Project included
This is a Demo Project to illustrate a basic problem with Voyager navigation, lifecycle handling and configuration changes.
Using Voyager (HomeScreen wrapped by Navigator) leads to problems with ...
1
vote
0
answers
201
views
Not executing the registerActivityLifecycleCallbacks in the Andrid Application class. How to make this to execute and show the ads
I am fetching the network preferences from the remote config and based on the value I am showing the ads to user. But it failed to show the ads when it is from the Application class.
@Override
...
1
vote
0
answers
45
views
How to know if fragment is recreated after back press and popBackStack()?
I have a two fragments, A and B. Let say fragment A is a person form and B is a city searcher.
In fragment A, I query the database server for some data, and until I get this info I display a ...
2
votes
1
answer
48
views
Android: Kotlin: running tasks upon app closing [closed]
While a user moves around my app I collect key events in a list. When the user quits the app I want to:
write that list to a file; and
upload that file to the cloud for analysis on the backend
I put ...
3
votes
2
answers
155
views
Why is my WorkManager worker not being triggered in onDestroy?
I’m facing an issue with triggering a WorkManager worker from the onDestroy method of my MainActivity. Here's the scenario:
I’ve implemented a ClearCacheWorker using WorkManager to handle background ...
0
votes
1
answer
29
views
Sticky eventbus only gets called when I enter to activity
I have two Activities, I am trying to send event from activity A to activity B without entering to activity B.
I am trying to do it with sticky eventbus, the problem is the event does not get trigger ...
1
vote
1
answer
67
views
How to specify which Android Activity should be launched after a configuration change?
I have two activities - LaunchActivity and GameActivity. It's necessary for LaunchActivity to open first because it launches GameActivity with configuration parameters. This is working fine except ...
2
votes
0
answers
45
views
onResume begin called when app is in background on launch
On Android 14, If I'm launching an app while the device is locked, it will call onResume/onPause, while the app is in the background. This is causing issues with NFC intent registration, because the ...
0
votes
1
answer
105
views
Text display in random position in all other activities of app, by triggering from one activity
I have Main, Home activities are there Launcher app side (.apk). PlayActivity, Profile, and Init are there on the library side (.aar)
from the server side 1 message will trigger, then I want to show ...
1
vote
1
answer
102
views
How to Refresh a Feed When Returning from the Background in Android?
I want to refresh my feed in an Android app, but only when the app is brought back to the foreground (e.g., from the background or when the user minimizes and reopens the app).
The refresh should not ...
0
votes
0
answers
95
views
Fragment’s View Not Visible After Returning from Background in Jetpack Compose App
Question:
I’m developing an Android app using Jetpack Compose and Fragments. I’m experiencing an issue where the view inside a Fragment is not visible when the app returns from the background under ...
0
votes
1
answer
100
views
Fragment UI visible through other fragments after theme switch even though onDestroyView() is called
This is a strange one. I have a standard application using tab navigation with one MainActivity and four Fragments that are swapped whenever a user clicks on a bottom tab.
Here's how the Fragments are ...
2
votes
3
answers
554
views
Call viewmodel function only one time when composable opened - Compose Android
When the compose screen is opened for the first time, I want to call function like list api or detail api.
I am currently using LaunchEffect(true) to call such function but the issue is that it is ...
0
votes
1
answer
40
views
Using on attach on dialog does not let the override method on fragment get called
I am using a dialog that has a click, I want to save the listener of click on "onAttach" from configuration changes, the problem is that it prevents the override method of listener on my ...
0
votes
1
answer
27
views
Observing data from the SharedViewmodel on two different fragments does not work correctly
I am filtering data in a bottomsheet that can be open in two different fragment in the different activities, when I filter the data on Fragment A, they save on viewmodel, but when I enter to Fragment ...
1
vote
1
answer
632
views
Why is my @Composable function in Jetpack Compose called after onResume instead of onCreate?
I'm learning how to develop an Android app using Jetpack Compose, and I'm currently working through understanding the activity lifecycle. I noticed an unexpected behavior: my @Composable function is ...
-1
votes
1
answer
265
views
open react native app on receive push notification without click on notification
I want to open react native app when the device gets a push notification.
I have used this code to open the app It works fine only on Android version less then 10. but it does not work on Android ...
1
vote
0
answers
74
views
Widget is not updated after widget update is stopped and started again
In my system, LauncherActivity is the main screen in Homescreen and it handles the widget updates. In onStart method, AppWidgetHost.startListening is called. In onStop method, AppWidgetHost....
1
vote
3
answers
5k
views
Compiler error migrating to androidx.lifecycle 2.8.0 library
I am using:
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
annotationProcessor 'androidx.lifecycle:lifecycle-common-...
0
votes
1
answer
75
views
Why does Android Developer document illustrate that Activity's onDestroy is called before ViewModel's onCleared?
I used debugging points to figure out the order of ViewModel's onCleared and Activity's onDestroy().
Because ComponentActivity class had below code, I knew ViewModel's onCleared() called and then ...
62
votes
4
answers
10k
views
java.lang.IllegalStateException: CompositionLocal LocalLifecycleOwner not present
I get an java.lang.IllegalStateException: CompositionLocal LocalLifecycleOwner not present error when I collectAsState() or collectAsStateWithLifecycle(). I do not know what is wrong. This previously ...
0
votes
1
answer
67
views
Activity onStop is received for previous activity instance after onResume during fast transition
The Launcher activity is responsible to handle the widgets of Homescreen. In onStart it calls appWidgetHost.startListening and in onStop it calls appWidgetHost.stopListening(). The expectation is when ...
0
votes
0
answers
11
views
I have created all the method of app life cycle and a Toast message inside to,only the onResume() and onStop() Toast is appearing [duplicate]
I am learning app life cycle.I have created methods of app life cycle and a toast message inside to know when the methods are called.I dont know what has gone wrong.
package com.example.layout;
...
0
votes
1
answer
46
views
Can skipping onStop() be used an indicator of crash?
The scenario of an Android app is like the following
MainActivity
- FooActivity1
- FooActivity2
The app starts with MainActivity which can start FooActivity1 and FooActivity2.
I am trying to ...
0
votes
0
answers
98
views
Prevent killing of android process when app is in background
I am stuck in a situation where user goes to capture image to set in an image view in an activity but as soon as user returns after capturing image, activity gets restarted.
Same case happens when ...
0
votes
0
answers
37
views
App launch icon click causes all activities to be destroyed
In our app, there are several activities.
When the user opens MainActivity-> EventActivity-> EventRegsiterActivity, and then clicks the home button we have an inconsistency behaviour.
When the ...
4
votes
2
answers
2k
views
Android Jetpack Compose: ViewModel state resetting on tab switch
I'm developing an Android app where I have a bottom bar. I am using Jetpack Compose, hilt and ViewModel. I have a ViewModel (ShopListHomeViewModel) that manages the state of a screen (...
1
vote
1
answer
746
views
How to use Lifecycle in Compose Multiplatform?
Recently, lifecycle library has been updated so it should be possible to use it in Compose Multiplatform.
The issue is that I can't get it to work. I try to add lifecycle observer, but when I try to ...
1
vote
0
answers
39
views
Android is queueing 'startActivity' if called twice immediately?
Consider this Activity that upon a button press calls startActivity twice. I have no real use case here, I am just trying to understand this scenario in theory.
public class MainActivity extends ...
1
vote
0
answers
878
views
Can't find Transformations in androidx.lifecycle
I've got an unresolved failure while importing androidx.lifecycle.Transformations after adding the related dependencies in the build.gradle.kts:
enter image description here.
Following are the ...
0
votes
1
answer
31k
views
java.lang.IllegalStateException: No instantiated fragment for (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) crash in Android
I rarely get a crash in my Android logs with a stack trace like this:
java.lang.IllegalStateException: No instantiated fragment for (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
at android.app.ActivityThread....
3
votes
4
answers
1k
views
lifecycleScope.launchWhen*** is deprecated. What's the alternative?
Before we could use:
lifecycleOwner.lifecycleScope.launchWhenStarted {
// Do something async
}
But now it's deprecated.
This one is also deprecated:
lifecycleOwner.lifecycleScope.launch {
...
5
votes
0
answers
747
views
LifecycleStartEffect.onStopOrDispose is called twice on navigating to another screen
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("...
2
votes
0
answers
107
views
Process is not killed even after swiping off from the recents screen
I have a camera app with options like photo, video, bokeh. If I goto recent and swipe up from there and relaunch the app, then it should open at photo option again regardless of which option I was ...
0
votes
2
answers
107
views
kotlin-coroutine can not be launched
when my fragment go backgroud of system, it invoke onStop().and then when my fragment go front desk of system, it invoke onResume(). but mainViewModelScope does not lanuch a coroutine.
my fragment
...
1
vote
0
answers
90
views
Activity instance does not refill again after onDestroy
I have an interface:
interface PermissionLauncher<in T> {
fun bindLauncher(launcher: T)
fun updatePermissionsStatus()
}
And I implemented it for activities:
class BindLauncherException :...
0
votes
1
answer
52
views
update include tag data when app theme changed (recreating Activity)
I used multiple include tags in a xml layout like this:
<include
android:id="@+id/firstView"
layout="@layout/layout_edit_text"
android:layout_width="...
0
votes
1
answer
359
views
Clicking overview(recent) button on android device doesn't call onPause() and onStop() method. Why is that?
I remember that when I used the Android version 9 device before, when I clicked the Overview button, called the onPause and onStop method.
However, these method are not being called on Android 12th ...
2
votes
2
answers
851
views
Compose View Not Recomposing on state changes
Was looking into Neo Launcher Feeder on github.
Found an issue where the compose view in the ComposeOverlayView is not recomposing despite state changes. I have modified the setContent in onCreate to ...
0
votes
1
answer
88
views
How to use a viewpager inside another fragment and not get any lifecycle issues?
This is my profile fragment where I am using a viewpager :
@Suppress("DEPRECATION")
class ProfileFragment : Fragment() {
private lateinit var viewPagerAdaptor: ViewPagerAdaptor
...
1
vote
1
answer
85
views
RecyclerView item selection not working as expected when minimizing and maximizing app
After minimizing my app and coming back to my app again to select item from recycler view then the imageview checkbox and color filter that marks recyclerview item as checked disappear but when I ...
0
votes
1
answer
43
views
Why is there an extra onPause onResume when launching action call?
I have a simple setup that launches the dialer to make a call using ACTION_CALL
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
1
vote
1
answer
94
views
OnResume called in quick succession
My app has a crash happening on production, the cause is due to a java.util.ConcurrentModificationException.
In the Breadcrump of the crash log, I noticed that the activities's onResume was called ...
0
votes
1
answer
69
views
new observers being created when observing lifedata after putting app to background
I have the following in my viewmodel
val currentStockPriceAsLiveData: LiveData<UiState> = stockPriceDataSource.latestStockList
.map { listOfStock ->
UiState.Success(...
5
votes
0
answers
3k
views
Is this a bug in later Android versions or a problem with my code? Spinner not firing listeners
I've got a bug that has been frustrating me for months now and I can't seem to get to the bottom of it despite a lot of searching.
The issue seems to be to do with when the OnItemSelectedListener of a ...