Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing two android apps and communicating between two

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?

like image 207
user1810931 Avatar asked Mar 08 '13 19:03

user1810931


People also ask

How can Android communicate with two apps?

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.

Can Android apps communicate with each other?

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.

How do I transfer data from one Android app to another?

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.


1 Answers

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

like image 114
iTech Avatar answered Sep 21 '22 15:09

iTech