I'm trying to create an AccountAuthenticator
to be used with multiple of our apps (so one account in the system-settings used by multiple apps). Just like all Google-apps use the same account on the system.
The problem is: How can I set it up that only one app (we don't know which it will be) needs to be installed and when a second app gets installed, it can just re-use an existing account?
I've created my AccountAuthenticator
using this tutorial and embedded into a library-project which gets included in all our apps. This works fine when only one app is installed.
As soon as a second app gets installed and the user tries to login, the system shows the intent-chooser dialog where he can pick both of our apps (because they both use the same authenticator-library with the same intent-filter). This should be the problem as well here (but I havn't verified it yet).
With some research you'll stumble across sharedUserId
and this tutorial. But this "solution" has the problem, that you need some kind of always-first-installed app with the authenticator in it. Plus, with the new Google Play App Signing a sharedUserId
seems impossible because every app will be signed with a different signature.
There might be a way to grant other apps access to the authenticator but there's still the problem that the authenticator-app needs to be installed first (as suggested here).
How can I solve this? How can I share an AccountAuthenticator
with multiple apps without installing an app holding it first? How does Google do it? Do they have their authenticator in the Play Services?
Google Play App signing allows you to re-use the same signature across multiple apps, for precisely this sort of problem.
Just choose "Reuse signing key" when you see this screen: