android communication between two applications
29,330
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 viastartService()
from Application A, with results passed back via aPendingIntent
fromcreatePendingResult()
or aMessenger
or a broadcastIntent
or aResultReceiver
; 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.
Author by
androidTesting
Updated on July 25, 2020Comments
-
androidTesting almost 4 years
I need some help in how to start developing two android applications (on one phone) which communicate with each other.
- Application A sends a string to application B.
- 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.
- Application A writes in the console the received string from B.
-
trusktr over 11 yearsLet's say we have an app that needs to know if 5 other apps have a specific file in their data folder. What's the best mechanism to use so that the first app can send a message and receive a "yes" result string or true boolean from the first app that has the file?
-
L3K0V about 8 yearsAbout first option using
ResultReceiver
when I try to get result receiver parcelable from intent in my second application I got:E/Parcel: Class not found when unmarshalling: com.myapp.demo.DemoActivity$1
Is there some tricky part? -
CommonsWare about 8 years@L3K0V: I recommend that you ask a separate Stack Overflow question, where you can provide a minimal, complete, and verifiable example of your problem, which would include the Java stack trace and the code that the trace refers to.
-
L3K0V about 8 years@CommonsWare can you take a look please? stackoverflow.com/q/35067178/1274974
-
saulyasar over 3 yearsHi @CommonsWare can you check my question ? stackoverflow.com/questions/64478498/…