In my app, I have a service that runs in the background and sends a text every 5 seconds to the server
(basic 4 android)
And if I delete the app from the background of the phone, it runs again
So far there is no problem
But when I add a webview to the activity and load a URL, all services are closed after closing the app
And it won't run in the background anymore
Is there a reason?
The problem is when I use webview.loadUrl("https://.....")
Webview is not your problem. Your problem is that in Android, any Service can be killed at almost any time, and at any time when the app is in the background. It has nothing to do with Webviews, it's how Android works- Services are always killed 2 minutes after your app is backgrounded. If you use a foreground service it will stay open longer, but can still be killed at any time.