How can I avoid making users download a separate APK for account management?
Asked Answered
V

1

14

I have created a custom account type for two applications that I am developing. Now I am looking for a way for both apps to take advantage of this single account service. The documentation recommends the following.

One solution is to place the service in one small, special-purpose APK. When an app wishes to use your custom account type, it can check the device to see if your custom account service is available. If not, it can direct the user to Google Play to download the service. This may seem like a great deal of trouble at first, but compared with the alternative of re-entering credentials for every app that uses your custom account, it's refreshingly easy.

But I do not want to make my users download a separate APK just to be able to log in. What would be another solution that would allow both apps to have this functionality, without the burden of a separate APK?

Vapid answered 10/11, 2017 at 16:58 Comment(13)
i did not get your point exactly, but have you ever read about Building multiple flavors in android ?Invite
@Invite Yes, but how could that solve my situation?Vapid
Why don't you offers both apks with the services, and each check to the other one? This will avoid the download of the second and the user still can download it and use the serviceOecology
@MarcosVasconcelos How do I "check the other one"? Is there a way to install a different flavor based on whether or not another APK is already installed? Even if that is the case, what would happen if the user uninstalls the first application that now is the only application with the account service?Vapid
No, you can just launch the GooglePlayStoreApp with the other app link. The solution I propesed is to enable a Service exported=true that offers the sign-in to the other app, if you do in both sides the user needs to log only on one and dont need both appsOecology
@MarcosVasconcelos Ah, I misread your comment. This is a decent solution, but part of the reason for only bundling one service is so it doesn't take up more room on the user's device than it has to. From the documentation: "You don't want to bundle the service with all of your apps and have multiple copies of it taking up space on your user's device."Vapid
Never tought so, it wouldnt be more than 1mb i think, also it says "you dont want" not "you cant"Oecology
@MarcosVasconcelos That's true, I don't have to avoid multiple copies of the service. But I was looking to see if there was a solution that would allow me to. If not, I will probably just end up including the service in both apps.Vapid
You can also do a online service, send the deviceid (any good that you find) log in one together then in the second one you check if the id is thereOecology
@MarcosVasconcelos After finally getting around to implementing and testing this solution, I discovered that the AccountManager binds the accounts to the first app that is installed with the account service. If that first app is deleted, all of the accounts are deleted as well. This isn't ideal, and I think the only solution is to force users to download a separate APK.Vapid
But in my solution all apps have the same service that provides and consumes form the other ones.Oecology
Hello there @Vapid , I am facing the same problem. Did you manage to find a solution? If yes, could you tell me what to do?Fremantle
@QaziFahimFarhan Not one that doesn't involve multiple copies of the same service. As I mentioned in my last comment, it isn't an ideal solution, but that's the one we went with. Hoping users do not delete the "primary" app; if they do, they are forced to log in again.Vapid
S
0

Try Content Providers So your on app can read data of other app official link

Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process. Implementing a content provider has many advantages. Most importantly you can configure a content provider to allow other applications to securely access and modify your app data

There so many example and tutorial available on web. You need some research on this this is best way to communicate between two app. by using this you can get user details of another app.

let me know if you any other query.

Steato answered 20/11, 2017 at 12:44 Comment(1)
Content Providers manage data, not code; the AccountManager already handles accessing user data. I am looking for a way to manage the Service that interacts with the AccountManager.Vapid

© 2022 - 2024 — McMap. All rights reserved.