Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android communication between two applications

Tags:

I need some help in how to start developing two android applications (on one phone) which communicate with each other.

  1. Application A sends a string to application B.
  2. Application B receives the string for example "startClassOne", app B using a method starts classOne and gets the result. The result is sent back (again as string!) to Application A.
  3. Application A writes in the console the received string from B.
like image 660
androidTesting Avatar asked Jan 09 '11 11:01

androidTesting


People also ask

How do two different applications communicate with each other?

So how do apps ​“talk” to each other? An application programming interface (API) is an interface provided by an app that allows third parties to use it to extend their own functionality. In layman's terms, it means APIs allow programmers to connect to other websites or apps to enhance their own.

Do apps talk to each other?

A study showed that applications on the android phones are able to talk to one another and trade information. The biggest security risks were some of the least utilitarian apps that pertained to personalisation of ringtones, widgets, and emojis, the researchers said.

Can an app read data from another app?

Just as an app can send data to other apps, it can also receive data from other apps as well. Think about how users interact with your application and what data types you want to receive from other applications.

How can two Android apps run in the same process?

Step 1: Tap & hold the recent button on your Android Device –>you will see all the recent list of applications listed in chronological order. Step 2: Select one of the apps you wish to view in split screen mode –>once the app opens, tap & hold the recent button once again –>The screen will split into two.


1 Answers

Hello, i need some help in how to start developing two android applications (on one phone) which communicate with each other.

On the whole, you generally don't want to artificially split one application into two, particularly if you are the author of both.

That being said, you can:

  • have Application B expose a an IntentService that will be called via startService() from Application A, with results passed back via a PendingIntent from createPendingResult() or a Messenger or a broadcast Intent or a ResultReceiver; or
  • have Application B expose a Service with an API defined in AIDL, and have Application A bind to that service, then have Application A call methods on Application B, or
  • send a broadcast Intent from Application A to Application B, with results being passed back by the same roster of options in the first bullet above, or
  • have Application B implement a content provider, and have Application A use ContentResolver to manipulate that content provider
  • and so on

Be sure work through all of the security ramifications of what you are doing, since you are exposing an API not only for Application A to use, but for any application on the device to use, unless you secure it with permissions.

like image 147
CommonsWare Avatar answered Sep 28 '22 09:09

CommonsWare