I always stop services I've started via code (like a communication service) when the activity is paused and start them new if I need them (e.g. in resume). So far I never had problems doing this and I find it a good practice to "close" all unneeded ressources.
the last one was a endless loop because the runtime permission put the activity in pause because a os dialog appear
and after deny and back resume to the app the request starts again. then i found a better solution to handle it.
or if you use back in navigation or finish other activity the resume do something unwanted.
or if you open other activity the pause do something unwanted.
With runtime permissions all is clear. Like with activating another apps (for example, Camera) using intent.
But your app should expect resume - pause anyway, because user is able, for example, to click "Home" or "OverView" button.
Which troubles / side effects from OS do you know ?
With runtime permissions all is clear. Like with activating another apps (for example, Camera) using intent.
But your app should expect resume - pause anyway, because user is able, for example, to click "Home" or "OverView" button.
Which troubles / side effects from OS do you know ?
I always stop services I've started via code (like a communication service) when the activity is paused and start them new if I need them (e.g. in resume). So far I never had problems doing this and I find it a good practice to "close" all unneeded ressources.
It really depends on your requirements. There is no right or wrong here.
One of the main advantages of using services is that you are not tied to the activities life cycle. Nothing bad happens if the service keeps running in the background for a few minutes.
We talk about a style of programming. When everybody thinks - nothing bad that my app will eat a little resources without need, modern computers/smartphones are very powerful, the result will be limitations like in Oreo 8.
No. You let the OS take care of it. It is actually not problematic at all on Android 8+. Services are stopped after one minute.
On the other hand if you break the communication because the user pressed on the "recent apps" button (activity will be paused) then the user experience will not be perfect.