I have written a SIP client that makes and receives calls. However, when the application is minimized, it can be unloaded from memory and receive calls accordingly. How to implement an application similar to Skype (until recently), when on launch it appears in the status bar and works until the exit button is pressed? Surely there is an article on this topic, but my searches were not crowned with success.

  • 2
    well, there is a Service class that can work in the mode of preventing it from unloading it from memory - arg

1 answer 1

Judging by your confused testimony, we are talking about 3 different components of the application:

  1. Notification - component responsible for the appearance of the icon in the status bar
  2. Service is a kind of long-lived component, in principle, you can make it non-paged.
  3. BroadcastReceiver - component responsible for intercepting incoming calls. To make it "non-paged", it must be declared in the manifest with the flag exported=true

Compositionally do this:

  1. We expose the notification, so that when you click on it, the Activity your application starts.
  2. We hang BroadcastReceiver configured to filter incoming / outgoing SIP calls. When intercepting a call - BroadcastReceiver will raise the desired Activity
  3. The business logic of the application, which should always be at hand, is placed in the Service , so that you can access the Service from the Activity .

PS IMHO you can do without Service - but the taste and color ...