I got a service that start a new activity, while screen is off. I want the activity to stay on paused mode, and not get to the stopped mode. Is there a way to achieve this?
It seems like you want to run an activity in background when it quits. However, activity can't be run unless it's on foreground. In order to achieve what you want, in onPause(), you should start a service to continue the work in activity. onPause() will be called when you click the back button.
No. You don't have control over the Activity lifecycle. Any processes that you need to run while the screen is off must be executed in a Service
. You must rebuild the application state whenever the screen is turned back on. Always assume the Activity
can be wiped from memory at any time.
You can't do that. it will be killed anyway.
but you can use a Service
to receive Broadcast of Intent.ACTION_SCREEN_ON
and relaunch activity from Service.
to restart your Activity from service check here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With