0

I'm looking to share few strings between 2 android apps. For example, App B wants to know if user is logged in App A and the name of the current logged user.

Many example on stackoverflow are offering to use Shared Preferences (cf Data sharing between two applications). But android:sharedUserId is deprecated since Android 29 and could be remove at any time (https://developer.android.com/guide/topics/manifest/manifest-element#uid)

On the other hand, there is Content Provider. It seems very appropriate to share database, but it seems completely oversized to share a string.

So my question is : What would be the best option to share simple objects between apps since Android 29 ?

Mathieu H.
  • 800
  • 8
  • 21

1 Answers1

0

You can use a service with AIDL to share whatever you need between apps:

The Android Interface Definition Language (AIDL) is similar to other IDLs: it lets you define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

https://developer.android.com/guide/components/aidl

You may also need to define a query for Android 11 (API level 30)

<manifest package="com.example.game">
  <queries>
    <!-- Specific apps you interact with, eg: -->
    <package android:name="com.example.service" />
  </queries>
  ...
</manifest>
user3394003
  • 119
  • 1
  • 2