PendingIntent , BroadcastReceiver , IBinder all use this to connect activities and services, in some functionaries these things allow you to perform the same tasks, and in some you don’t, what are you choosing for?

Suppose there is a specific example that ForegroundService running and it sends messages to the Activity , so that the messages should be received by the Activity even after it has been deleted and rebooted.

    1 answer 1

    Intent is a “message” that sends your application somewhere “on the air”, not having an exact addressee, but having a unique “name”. It will be received by everyone in the system who is subscribed to receive messages with such a "name".
    PendingIntent differs from Intent in that it allows you to perform actions by the recipient of the "message" with the rights of the application that sent this intent. Normal intent is performed with the rights of the "receiving" application.

    BroadcastReceiver - the receiver sent by someone intent messages. It subscribes to listening to the "broadcast" and intercepts the interesting "messages" - indents by their "names".

    These two tools work in pairs. As it is easy to notice, in this scheme there is no clear link between the sender and receiver, any application in the system can receive and intercept the “message”. The link is open and completely “untied” - the receiver and the recipient know nothing about each other, except for the “name” -ent.

    IBinder - callback interface for communication service and application. Here, the absolute closed connection between different parts of the same program, the data sent via the interface will be received only where the callback method ( onBind() ) is located in the sending side of the interface. These parts are "rigidly" connected and cannot work one without the other.

    If we send intents, then the receiver, which is signed on them, will work even if the application is not launched at the moment (activation), provided that the application subscribes to these intents through the manifest, respectively, the activation will be launched.

    PS: By writing "after its removal" you mean that the activation is not running at the moment? if an application signed for an intent has been uninstalled (as you can understand “delete”), then it will not naturally be installed again to accept the sent intent, it will simply go “nowhere” if there are no other subscribers (receivers).