android-account

Mock up account in ActivityInstrumentationTestCase2

三世轮回 提交于 2019-12-07 08:20:36
问题 In my Activity, I get accounts in onCreate() : public void MyActivity extends Activity{ ... private Account[] accounts; @Override protected void onCreate(){ accounts = AccountManager.get(this).getAccounts(); } ... } Now, I am unit testing MyActivity in test project: public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> { ... @Override protected void setUp() throws Exception{ super.setUp(); //How to mock up the accounts in system so that some fake accounts could be

create custom account android

ぐ巨炮叔叔 提交于 2019-12-04 11:08:12
问题 Whats the simplest way to create a custom account on Android? So far I've read the documentation: Creating a Custom Account Type but it certainly didn't help a lot (too vague info). I tried reading the example from LastFm but certainly they did things a bit too much elaborated wich I quite didn't understand well since I'm just an Android begginer with the accounts. I know its not as simple as calling: final Account account = new Account(mUsername, your_account_type); mAccountManager

Android AccountManager.getUserData() returns null

不羁的心 提交于 2019-12-04 04:39:52
问题 I have a similar problem like this AccountManager getUserData returning null despite it being set But the solutions did not work for me My Authenticator.java public class Authenticator extends AbstractAccountAuthenticator{ private Context context; public Authenticator(Context context) { super(context); this.context = context; } @Override public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { // TODO Auto-generated method stub return null; } @Override public

AccountManager does not add custom account in Android N preview

ぃ、小莉子 提交于 2019-12-04 00:42:40
I have implemented a sync adapter in my app which requires an account to be added in the device account settings. I followed the same approach given in the Android docs. It works fine till Marshmallow and I can see my account listed in the device accounts. But in Android N preview, account does not add to the device accounts. AccountManager's addAccountExplicitly() method always returns false. Has anyone faced this problem? Not sure if this is the same issue, but there's an issue with AccountManager on the current version of the Android N image. Basically, if you: Add an account to

create custom account android

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 07:56:04
Whats the simplest way to create a custom account on Android? So far I've read the documentation: Creating a Custom Account Type but it certainly didn't help a lot (too vague info). I tried reading the example from LastFm but certainly they did things a bit too much elaborated wich I quite didn't understand well since I'm just an Android begginer with the accounts. I know its not as simple as calling: final Account account = new Account(mUsername, your_account_type); mAccountManager.addAccountExplicitly(account, mPassword, null); because this would trow an exception. So far I understood that I

Android AccountManager.getUserData() returns null

ⅰ亾dé卋堺 提交于 2019-12-01 21:55:06
I have a similar problem like this AccountManager getUserData returning null despite it being set But the solutions did not work for me My Authenticator.java public class Authenticator extends AbstractAccountAuthenticator{ private Context context; public Authenticator(Context context) { super(context); this.context = context; } @Override public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { // TODO Auto-generated method stub return null; } @Override public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,

Getting the Gmail Id of the User In Android 6.0 marshmallow

别来无恙 提交于 2019-12-01 09:34:35
问题 I am getting email id by using android.permission.GET_ACCOUNTS permission. try { Account[] accounts = AccountManager.get(this).getAccountsByType("com.google"); for (Account account : accounts) { emailid = account.name; Log.e("account",emailid); } } catch (Exception e) { Log.i("Exception", "Exception:" + e); } This code is working on all devices upto Lollipop 5.1. But its not working in Marshmallow 6.0. Can anyone help me to resolve this problem. I am not even getting any errors in logcat. 回答1

Pick an email using AccountPicker.newChooseAccountIntent

我与影子孤独终老i 提交于 2019-11-28 05:26:42
I'm trying to let the user pick an Email account using the following code: Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, false, null, null, null, null); startActivityForResult(intent, 23); This code works great but if the user doesn't have a Gmail account but Yahoo, Hotmail, etc.. How can I show all Email accounts by changing the third parameter: new String[]{"com.google"} Thank you very much According to the docs, the third parameter is allowableAccountTypes : allowableAccountTypes an optional string array of account types. These are used both to

How to add whatsapp like options to contact whenever the is a new contact added to Contacts

北战南征 提交于 2019-11-27 09:07:59
I develop an app which needs to do 2 things: Create a user account (like WhatsApp). Whenever there is a new contact entry, if the contact is using my app, then immediately in the Contacts application show options "call" or "message" in the contact detail page. Example You need to create a SyncAdapter , this is basically a service that is able to sync contacts to/from a server, like Google does for Google Contacts , you can set it to be notified when a new contact is added, and have your SyncAdapter add the needed info to the contact so it'll show links to your app. If you go to your phone

How to maintain session in android?

折月煮酒 提交于 2019-11-27 03:25:57
Can anybody tell me how to maintain session for a user login. For example when the user sign- in to an application they have to be signed in unless the user logouts or uninstall the application similar to gmail in android. Bhanu Sharma Make one class for your SharedPreferences public class Session { private SharedPreferences prefs; public Session(Context cntx) { // TODO Auto-generated constructor stub prefs = PreferenceManager.getDefaultSharedPreferences(cntx); } public void setusename(String usename) { prefs.edit().putString("usename", usename).commit(); } public String getusename() { String