I'm working on the open source project Linphone , when the application is closed it is not working in the background, so if someone makes me a link in the mean time I am not notified, how can I handle this problem?
I'm working on the open source project Linphone , when the application is closed it is not working in the background, so if someone makes me a link in the mean time I am not notified, how can I handle this problem?
A Service
is a component of what can perform long operations and does not provide a user interface. Another component of the application can start a service and it will continue running in background even if the user switches to another application.
you can use.[...] In addition, a component may be linked to a service to interact with it and even establish interprocess communication (IPC). For example, a service can handle network operations, reproduce music, perform file I / O, or interact with a content, all from the background.
<manifest ... >
...
<application ... >
<service android:name=".ExampleService" />
...
</application>
</manifest>
The IntentService
class provides a simple structure for performing an operation on a single background segment. This allows you to handle long-running operations without affecting the responsiveness of your user interface.
This is a subclass of Service that uses a work thread to handle all startup requests one at a time. This is the best option if you do not want the service to handle multiple simultaneously. All you need to do is implement onHandleIntent (), which receives the intent for each start so you can perform background work.
To create a IntentService
component for your application, define a class that extends IntentService , and within it, define a method that replaces onHandleIntent()
. For example:
public class RSSPullService extends IntentService {
@Override
protected void onHandleIntent(Intent workIntent) {
// Gets data from the incoming Intent
String dataString = workIntent.getDataString();
}
}
For more details, check the documentation .