We developed an app which is running in android payment device(PAX). This device having low memory (1 GB). In this app we are calling other app using ActivityResultLauncher and getting the result to store in our DB.
Out of 1000 cases 1 or 2 times our app is got killed while waiting for result and our app in background.
Here my doubts: 1)Is it possible to avoid that, my app got killed by Android 2)Is it possible to maintain the same state after app got killed, so when our app come to foreground we can capture the activity result..
We are using android:largeHeap="true"
CodePudding user response:
not sure how long are you waiting for result, but maybe some battery optimisation mechanism is killing your app in the meantime
check out REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, maybe this "perm" prevent problem
CodePudding user response:
Is it possible to avoid that, my app got killed by Android
You can increase priority of your application, for example by starting foreground service, but anyway you should be ready that your app can be killed.
Is it possible to maintain the same state after app got killed
Android provides all tools for it, you can read about them here.