Android AccountManager alias for name - android

I'm using AccountAuthenticator and SyncAdapter in application, for accounts stored in AccountManager I use my own ACCOUN_TYPE and server specific identifier as ACCOUNT_NAME (Let's say "com.example.account_type" and "xxx-long-hashed-id" respectively).
I have to use this identity to keep that account distinct from another, because as far as I understand AccountManager uses both type and name to ensure account uniqueness.
The problem is, when I open system Settings->Account page for my app I see this ugly identifier as name, but I wanted put there username associated with this identity (I also see this in Contacts app - I export contacts there). If I started to use username as ACCOUNT_NAME, any time I change username in my app, I would see another account there, although it should be the same. Is there any way or workaround to use identity as name, but provide user-readable name to the system?

No, there is no alias mechanism for accounts in Android. Using the actual username is the intended way to create accounts. If you need to change the account name, you have to remove and re-add the account. For API level 21+ there is a method called AccountManager.renameAccount(...) but it does essentially the same. It's up to your app to migrate any data from the old account to the new one, Android won't do that for you.
Regarding the uniqueness of accounts, it's sufficient if the account name is unique among all accounts of your account type. So given all users of your service have unique usernames, there is nothing to worry about.

Related

How to check domain of Google Account in my app login screen?

I am trying to create a login screen within my android app, and restrict access to the "private" (or password protected) section of the app to users of a specific organization.
Knowing that the organization accounts are all Google Accounts (with either of two domain names (eg. user.name#domain1.com or user.name#domain2.com)), how can I check and only allow users with those two email types to access the app?
I was thinking of checking whether the domain corresponded to either of the ones used by the organization, but I am not quite sure how to go about this.
Any help is much appreciated.

Same account, multiple applications

I am developing an SDK which multiple applications will use. This SDK should login to the user's account and will provide the application with server interaction works. My problem is that I want to share this user's account between these applications. So there should be a mechanism in which applications will first look up the account if it exists, they will use it, if not, they will create it. But I am having technical challenges.
I looked up android's custom accounts so that the account credentials could be stored there. But I am not sure if it is possible there. First, is it possible to see if an account under a certain type exists? Second, is it possible for an application to use an account which another application created? For example, google games is doing exactly this functionality. Any game can login with user's google game account. But I need to do this without installing a third-party service on user's device.
Generally, if you have anything helpful to solve this situation, it is much appreciated.
If you looking for a solution on the device you can use a content provider to share data between the two apps.
After digging deep in the explained situation, I got my answer
First, yes it is possible to see if there exist an account under an specific name. This name can be different from the application's URI.
Second, it is possible to use an account which another application has been created.
So in the SDK, I can first lookup a contracted account name which there will be an stored token. If it exists, the SDK will store it in the shared preferences. If it does not exist, the SDK will create the token using the user's credentials. This way, other applications can use this account and if the application which created the account has been uninstalled, the next application which runs, will recreate the token in accounts from its shared preferences.

Organizer.displayName is null for some users

I am using the Google Calendar apps API in Android. For some users in my organization the field displayName is always null for an Organizer* instance that represents them. To get the organizer and display name I call eventInstance.getOrganizer().getDisplayName().
It's not for all accounts, though. I can't figure out the pattern here. Does something need to be set in their Google account? Why would the display name not be available, anyway?
P.S. - I haven't gotten to parsing attendees yet but I assume the same issue will exist there.
References:
* com.google.api.services.calendar.model.Event.Organizer
It usually happens to users who have not enabled Google+ on their accounts. You can refer here. For now, make sure that you enable Google+ on your domain and then on your account. If still persists, try deleting the account from your app's accounts list for your account to be updated properly.

Single Android Account for multiple apps

in my company, we have two apps that access an authentication (from our own webservice) token from the android account manager. Because this is a SSO, we decided to extract the login (activity and AbstractAccountAuthenticator) into a library, that both apps are binding to.
In order to keep the account in the android system, if one of our apps gets uninstalled (assuming the user installed both of our apps), we gave the accountType a unified name ex. my.company.auth (both apps however have the package name my.company.a and my.company.b respectively).
The problem lies when both of our apps gets uninstalled: the entry in the account settings in android is still there.
Does anyone know why or what I am doing wrong?
Does it have to do with the accountType, that has a different 'package name' then the apps?
Thank you very much in advance
You need to separate your custom account type component and provide a separate apk file.
When user tries to use any of your app, you need to check if custom account type app exsits on the device or not.
If your account type app doesn't exist, direct user to playstore for downloading your custom account type app so that user can create account for your custom account type and continue to use your app.
In this way, since user created account is not tied to one app and custom account type is separate app, uninstalling any of your app won't delete account created for your custom account type.

Facebook API (for android) : does the userID remain when android app updates

According to this documentation, Facebook's userID is dependent of the app that requests the userID, i.e., the useriD is different for each app that requests the userID.
My question is the following. Will the userID remain the same for my app when:
My app will be updated on the play store (or apple store)?
A user uses another phone to login to my app via Facebook?
It is not clear to me how I can make sure that the userID will remain the same.
The reason I ask this question is that I would like to provide my users with Facebook auth to my app. However, I need to be able to identified each and every user with a unique identifier (in this case, it would be the userID). User's email or phone number can't be used as unique identifiers as it is not guarantied that users have filled these info on Facebook (even though it is one or the other, I would prefer to have another unique facebook-related identifier of my users).
Maybe I have misunderstood the documentation, in this case, I apologise and thank you for pointing me to the part of the doc that answers my questions.
Regards
It is different for each Facebook app ID. So as long as you use the the same Facebook app ID it will not change.

Categories

Resources