Search code examples
javaandroidpluginspermissionsandroid-permissions

Communication between an app-plugin to a service of a different app [Android]


I am new to this so can you please help me by pointing me to the right direction on how I can achieve this.

I have 2 apps

1) App that has the service - APP1

2) App that has the plugin - APP2

The scenario:

APP2 would like to access the server of APP1, so that it can send its data from its source app. APP2 would then have to access APP1's service in order to do so.

The process:

APP2 STARTS UP -> APP2 PLUGIN -> SENDS DATA -> APP1 Service -> APP1 Server

APP1 Server -> APP1 Service -> SENDS DATA -> APP2 PLUGIN -> Do action to APP2 based on result

Thanks in advance! I really am at a loss on this one.


Solution

  • The following methods can be used.

    1. ContentProvider:

    A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access.

    For more info: content-provider-basics

    You can use permission,readPermission,writePermission for security.

    <provider  
              android:permission="string"
              android:readPermission="string"
              android:writePermission="string" >
        . . .
    </provider> 
    

    For more info: provider-element

    2.broadcast:

    Android apps can send or receive broadcast messages from the Android system and other Android apps, similar to the publish-subscribe design pattern. These broadcasts are sent when an event of interest occurs. For example, the Android system sends broadcasts when various system events occur, such as when the system boots up or the device starts charging. Apps can also send custom broadcasts, for example, to notify other apps of something that they might be interested in (for example, some new data has been downloaded).

    For more info Broadcasts