Android app in the background [duplicate]

5

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?

    
asked by anonymous 10.10.2016 / 16:39

1 answer

1

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.

  

[...] 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.

Here is an example

you can use.

Service in manifest.xml

<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 .

    
10.10.2016 / 17:00