accountmanager

How can I access the Google account user_id?

一笑奈何 提交于 2020-01-03 04:35:11
问题 I'd like to access the user's Google account user_id for authentication, but I don't see any mention of this in the AccountManager. How can my app request the user_id ? 回答1: Now that Google Play Services is available, you can use it to request the user's permission to access the https://www.googleapis.com/auth/userinfo.profile scope and, with the resulting access token, make a request to https://www.googleapis.com/oauth2/v1/userinfo?access_token={accessToken} to get their user ID. 回答2: You

How to get an icon associated with specific Account from AccountManager.getAccounts()

让人想犯罪 __ 提交于 2020-01-01 08:35:22
问题 There is an icon displayed in account settings for each account. For Google account there is one icon, for Facebook another. Is there a way of getting this icon from the code in application? 回答1: Finally, I solved it: private Drawable getIconForAccount(Account account, AccountManager manager) { AuthenticatorDescription[] descriptions = manager.getAuthenticatorTypes(); PackageManager pm = getContext().getPackageManager(); for (AuthenticatorDescription description: descriptions) { if

What protects Android AccountManager passwords from being read by other apps?

混江龙づ霸主 提交于 2020-01-01 04:19:39
问题 I'm writing 1) an app that stores a username and password in the AccountManager, and 2) a separate background Service app that accesses those credentials to login to my servers, etc. Playing around with this, I find I'm able to call AccountManager.getPassword(account) from the Service (app 2) to access the type of accounts I've add to the AccountManager using the other app (app 1). Due to this, I'm starting to wonder what stops an arbitrary malicious app from 1) including the fields in the

What protects Android AccountManager passwords from being read by other apps?

倖福魔咒の 提交于 2020-01-01 04:19:05
问题 I'm writing 1) an app that stores a username and password in the AccountManager, and 2) a separate background Service app that accesses those credentials to login to my servers, etc. Playing around with this, I find I'm able to call AccountManager.getPassword(account) from the Service (app 2) to access the type of accounts I've add to the AccountManager using the other app (app 1). Due to this, I'm starting to wonder what stops an arbitrary malicious app from 1) including the fields in the

AccountManager getUserData returning null despite it being set

妖精的绣舞 提交于 2020-01-01 04:12:25
问题 I'm working on an Android app that uses the AccountManager to store accounts & credentials. One problem I've been having is that even though I pass in a bunch of String values to the AccountManager's addAccountExplicitly data bundle. I have checked to make sure that the bundle is not empty and that it contains the values before adding the account. And most of the time this is the case, but every once in a while I get null when I query these values. The null return values are more common after

Android multiple sync adapter items like Google Account?

一笑奈何 提交于 2019-12-30 01:08:29
问题 I currently have my Android app set up to use the AccountManager feature of Android, using a SyncAdapter and an authenticated account to performs syncs automatically. I only have 1 sync adapter running which syncs all content, but I would like to separate this out to performs syncs for different content at different intervals. How can I have multiple sync items like Google does? 回答1: You just have to define several sync adapters, using the same account type. The manifest contains: <service

Add account automatically

旧街凉风 提交于 2019-12-29 05:37:45
问题 My application needs to synchronize some data from server. I added necessary classes (similarly to SampleSyncAdapter) now I can add account via "Settings/Sync and Accounts". But I want to have already added my account and working synchronization just after application is installed (I do not want user to do any manual changes in settings). How to do this? 回答1: There is Android AtLeap library which contains helper classes to use Account Authenticator. Have a look at it https://github.com

Autoadd account after application is installed

[亡魂溺海] 提交于 2019-12-25 18:43:08
问题 Is there any way to add automatically account just after installation my application (but it was not started yet). 回答1: It is impossible to do anything "just after installation my application (but it was not started yet)". When the user launches your main activity, you can set up the account or whatever other sort of first-time event you want. 回答2: Here is a peace of code which automatically activates account final AccountManager accountManager = AccountManager.get(this); String authority =

Trouble capturing activity result when firing Intent received from AccountManagerFuture

烂漫一生 提交于 2019-12-25 02:03:43
问题 I am trying to follow Authenticating to OAuth2 Services and implement the part where an Intent is included in the Bundle provided by the AccountManagerFuture#getResult() call. The issue is, that even though the docs say to use Activity#startActivityForResult(...), the Intent I am told to fire apparently starts in its own task, resulting in onActivityResult being called immediately. Another part which I am uncertain I am doing correctly is the way I launch this Intent. Because the code that

AccountManager only returning one account in extended activity

99封情书 提交于 2019-12-25 01:21:25
问题 I have a simple app which is an extended activity that registers a user's primary email account when accessing a specific NFC tag. Unfortunately, for some reason even though I can see several accounts provisioned on my Samsung device the code below only returns one, and not the full list. The one it returns appears to be the Samsung account ID and not the Google ID. Is this a simple case of user error or is there some other way to get to the Google ID? This code has been updated to reflect