I am developing two applications names A and B.
Application A as activity named MainActivity
, service called UpdateService
, BroadcastReciever
called UpdateReceiver
.
Application B as activity named TestActivity
, service called DoService
, BroadcastReciever
called DoReceiver
.
In my application B, I want to access few methods and code from MainActivity
which is in Application A.
In this way, I need full control of Application A code to access it in my application B.
How can I achieve it?
Android inter-process communication At the simplest level, there are two different ways for apps to interact on Android: via intents, passing data from one application to another; and through services, where one application provides functionality for others to use.
Android apps are screened for viruses and other security issues before being listed in the Google Play store, but only individually. Once downloaded, apps can communicate with each other without notifying the user.
Android uses the action ACTION_SEND to send data from one activity to another, even across process boundaries. You need to specify the data and its type. The system automatically identifies the compatible activities that can receive the data and displays them to the user.
You cannot directly access methods of Activity
in different app.
Broadcast
would work but if you want more control (i.e. invoke remote methods) consider binding to a remote service in the other app or use Messenger
and handler to communicate.
Here is a short tutorial on inter-app communication
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With