Ephraim Ansar
Ephraim Ansar

Reputation: 3

background process|service in android studio

I cant find any answers on google cause IDK how to state the problem. I want to know how do you put a background process or function in android which timely do some operations like checking for new notifications, the background process should be working the whole time in any activity, even when application is closed.

Upvotes: 0

Views: 49

Answers (2)

VasFou
VasFou

Reputation: 1669

You should read this article about Services . But also, you should read about some limitations that there are especially for Android Oreo and above. For example if you have your app closed the OS may kills your Services. Check this link for Background Execution Limits . If you are looking for notifications you should implement a Service that extends MyFirebaseMessagingService and override onMessageReceived method. Please check this link.

Upvotes: 1

Maksym S.
Maksym S.

Reputation: 151

Please check the documentation on Foreground Service.

Note: You need to show a notification in order to launch Foreground Service. And don't forget that your Service is running on UI thread.

Upvotes: 0

Related Questions