android.accounts.Account Java Examples

The following examples show how to use android.accounts.Account. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public void setSyncAutomaticallyAsUser(Account account, String providerName, boolean sync,
                                       int userId) {
    if (TextUtils.isEmpty(providerName)) {
        throw new IllegalArgumentException("Authority must be non-empty");
    }
    mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
            "no permission to write the sync settings");
    enforceCrossUserPermission(userId,
            "no permission to modify the sync settings for user " + userId);
    final int callingUid = Binder.getCallingUid();
    final int callingPid = Binder.getCallingPid();
    final int syncExemptionFlag = getSyncExemptionForCaller(callingUid);

    long identityToken = clearCallingIdentity();
    try {
        SyncManager syncManager = getSyncManager();
        if (syncManager != null) {
            syncManager.getSyncStorageEngine().setSyncAutomatically(account, userId,
                    providerName, sync, syncExemptionFlag, callingUid, callingPid);
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
Example #2
Source File: DisplayActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get Account information
    Account[] mAccountList = AccountManager.get(this).getAccountsByType("com.google");

    // Must have a Google account set up on your device
    if (mAccountList.length == 0) finish();

    mType = mAccountList[0].type;
    mName = mAccountList[0].name;

    // Insert new contacts
    insertAllNewContacts();

    // Create and set empty list adapter
    mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, null,
            columnsToDisplay, resourceIds, 0);
    setListAdapter(mAdapter);

    // Initialize a CursorLoader
    getLoaderManager().initLoader(0, null, this);
}
 
Example #3
Source File: Config.java    From TimberLorry with Apache License 2.0 6 votes vote down vote up
public Config build(Context context) {
    if (config.bufferResolver == null) {
        if (config.account == null) {
            config.account = new Account("TimberLorry", "timberlorry.drivemode.com");
        }
        config.bufferResolver = new DefaultBufferResolver(
                (AccountManager) context.getApplicationContext().getSystemService(Context.ACCOUNT_SERVICE),
                context.getApplicationContext().getContentResolver(), config.account);
    }
    if (config.serializer == null) {
        throw new IllegalStateException("Serializer cannot be null.");
    }
    if (config.outlets.isEmpty()) {
        throw new IllegalStateException("You need to add at least 1 OutputPlug.");
    }
    if (config.collectPeriod == 0) {
        throw new IllegalStateException("You need to specify collect period in second.");
    }
    return config;
}
 
Example #4
Source File: Uploader.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log_OC.i(TAG, "result received. req: " + requestCode + " res: " + resultCode);
    if (requestCode == REQUEST_CODE_SETUP_ACCOUNT) {
        dismissDialog(DIALOG_NO_ACCOUNT);
        if (resultCode == RESULT_CANCELED) {
            finish();
        }
        Account[] accounts = mAccountManager.getAccountsByType(MainApp.getAuthTokenType());
        if (accounts.length == 0) {
            showDialog(DIALOG_NO_ACCOUNT);
        } else {
            // there is no need for checking for is there more then one
            // account at this point
            // since account setup can set only one account at time
            setAccount(accounts[0]);
            populateDirectoryList();
        }
    }
}
 
Example #5
Source File: Utils.java    From kolabnotes-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static final String getNameOfActiveAccount(Context context, String pemail, String prootFolder){
    AccountManager accountManager = AccountManager.get(context);
    Account[] accounts = accountManager.getAccountsByType(AuthenticatorActivity.ARG_ACCOUNT_TYPE);

    for(int i=0;i<accounts.length;i++) {
        String email = accountManager.getUserData(accounts[i],AuthenticatorActivity.KEY_EMAIL);
        String name = accountManager.getUserData(accounts[i],AuthenticatorActivity.KEY_ACCOUNT_NAME);
        String rootFolder = accountManager.getUserData(accounts[i],AuthenticatorActivity.KEY_ROOT_FOLDER);

        if(pemail.equals(email) && prootFolder.equals(rootFolder)){
            return name;
        }
    }

    return context.getResources().getString(R.string.drawer_account_local);
}
 
Example #6
Source File: AccountAuthenticator.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account)
    throws NetworkErrorException {
  final Bundle result = super.getAccountRemovalAllowed(response, account);
  if (result != null
      && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT)
      && !result.containsKey(AccountManager.KEY_INTENT)) {
    if (result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT)) {
      accountManager.logout()
          .doOnError(throwable -> crashReport.log(throwable))
          .onErrorComplete()
          .subscribe();
    }
  }
  return result;

  //
  // this indicates that the user must explicitly logout inside Aptoide and is not able to
  // logout from the Settings -> Accounts
  //

  //Bundle result = new Bundle();
  //result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
  //return result;
}
 
Example #7
Source File: LoginUtils.java    From android-galaxyzoo with GNU General Public License v3.0 6 votes vote down vote up
/** Don't call this from the main UI thread.
 *
 * @param context
 */
public static void removeAccount(final Context context, final String accountName) {
    final AccountManager accountManager = AccountManager.get(context);
    final Account account = new Account(accountName, LoginUtils.ACCOUNT_TYPE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //Trying to call this on an older Android version results in a
        //NoSuchMethodError exception.
        //There is no AppCompat version of the AccountManager API to
        //avoid the need for this version check at runtime.
        accountManager.removeAccount(account, null, null, null);
    } else {
        //noinspection deprecation
        //Note that this needs the MANAGE_ACCOUNT permission on
        //SDK <=22.
        //noinspection deprecation
        accountManager.removeAccount(account, null, null);
    }
}
 
Example #8
Source File: AccountsChangedReceiver.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void onReceive(final Context context, Intent intent) {
    if (AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(intent.getAction())) {
        final Account signedInUser =
                ChromeSigninController.get(context).getSignedInUser();
        if (signedInUser != null) {
            BrowserStartupController.StartupCallback callback =
                    new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    OAuth2TokenService.getForProfile(Profile.getLastUsedProfile())
                            .validateAccounts(context);
                }

                @Override
                public void onFailure() {
                    Log.w(TAG, "Failed to start browser process.");
                }
            };
            startBrowserProcessOnUiThread(context, callback);
        }
    }
}
 
Example #9
Source File: MyAccountActivity.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
private void removeAccount(final Account account) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sharedPreferences.edit().remove("queueName").apply();
    ContentResolver.setIsSyncable(account, WEBINSTALL_SYNC_AUTHORITY, 0);
    ContentResolver.setSyncAutomatically(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, false);
    if(Build.VERSION.SDK_INT>=8){
        ContentResolver.removePeriodicSync(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, new Bundle());
    }
    mAccountManager.removeAccount(account, new AccountManagerCallback<Boolean>() {
        @Override
        public void run(AccountManagerFuture<Boolean> future) {
            addAccount();
            finish();
        }
    }, null);
}
 
Example #10
Source File: AppUtils.java    From loco-answers with GNU General Public License v3.0 6 votes vote down vote up
private static String getUserIdentity(Context context) {
    if (ActivityCompat.checkSelfPermission(context, Manifest.permission.GET_ACCOUNTS) ==
            PackageManager.PERMISSION_GRANTED) {
        AccountManager manager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
        @SuppressLint("MissingPermission") Account[] list = manager.getAccounts();
        String emailId = null;
        for (Account account : list) {
            if (account.type.equalsIgnoreCase("com.google")) {
                emailId = account.name;
                break;
            }
        }
        if (emailId != null) {
            return emailId;
        }
    }
    return "";
}
 
Example #11
Source File: ContentService.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * If the user id supplied is different to the calling user, the caller must hold the
 * INTERACT_ACROSS_USERS_FULL permission.
 */
@Override
public boolean getSyncAutomaticallyAsUser(Account account, String providerName, int userId) {
    enforceCrossUserPermission(userId,
            "no permission to read the sync settings for user " + userId);
    mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS,
            "no permission to read the sync settings");

    long identityToken = clearCallingIdentity();
    try {
        SyncManager syncManager = getSyncManager();
        if (syncManager != null) {
            return syncManager.getSyncStorageEngine()
                    .getSyncAutomatically(account, userId, providerName);
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
    return false;
}
 
Example #12
Source File: ContentResolver.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @see #requestSync(Account, String, Bundle)
 * @hide
 */
public static void requestSyncAsUser(Account account, String authority, @UserIdInt int userId,
        Bundle extras) {
    if (extras == null) {
        throw new IllegalArgumentException("Must specify extras.");
    }
    SyncRequest request =
        new SyncRequest.Builder()
            .setSyncAdapter(account, authority)
            .setExtras(extras)
            .syncOnce()     // Immediate sync.
            .build();
    try {
        getContentService().syncAsUser(request, userId);
    } catch(RemoteException e) {
        // Shouldn't happen.
    }
}
 
Example #13
Source File: VAccountManagerService.java    From container with GNU General Public License v3.0 6 votes vote down vote up
public void confirmCredentials(int userId, IAccountManagerResponse response, final Account account, final Bundle options, final boolean expectActivityLaunch) {
	if (response == null) throw new IllegalArgumentException("response is null");
	if (account == null) throw new IllegalArgumentException("account is null");
	AuthenticatorInfo info = getAuthenticatorInfo(account.type);
	if(info == null) {
		try {
			response.onError(ERROR_CODE_BAD_ARGUMENTS, "account.type does not exist");
		} catch(RemoteException e) {
			e.printStackTrace();
		}
		return;
	}
	new Session(response, userId, info, expectActivityLaunch, true, account.name, true, true) {

		@Override
		public void run() throws RemoteException {
			mAuthenticator.confirmCredentials(this, account, options);
		}

	}.bind();

}
 
Example #14
Source File: AndroidStorage.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void create(int clientType, Account account, String authType,
    Intent eventIntent) {
  ComponentName component = eventIntent.getComponent();
  Preconditions.checkNotNull(component, "No component found in event intent");
  metadata = ClientMetadata.newBuilder()
      .setVersion(CURRENT_VERSION)
      .setClientKey(key)
      .setClientType(clientType)
      .setAccountName(account.name)
      .setAccountType(account.type)
      .setAuthType(authType)
      .setListenerPkg(component.getPackageName())
      .setListenerClass(component.getClassName())
      .build();
  store();
}
 
Example #15
Source File: LoginActivity.java    From MyOwnNotes with GNU General Public License v3.0 5 votes vote down vote up
private void useAccount(Account selectedAccount) {
    if (PreferenceManager.getDefaultSharedPreferences(this).contains(Settings.PREF_ACCOUNT_PASSWORD)) {
        new CheckAccountAsyncTask().execute(selectedAccount);
    } else {
        queryPassword(selectedAccount);
    }
}
 
Example #16
Source File: ExampleListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Returns any Google account enabled on the device. */
private static Account getAccount(AccountManager accountManager) {
  Preconditions.checkNotNull(accountManager);
  for (Account acct : accountManager.getAccounts()) {
    if (GOOGLE_ACCOUNT_TYPE.equals(acct.type)) {
      return acct;
    }
  }
  throw new RuntimeException("No google account enabled.");
}
 
Example #17
Source File: c.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
c(Account account, Bundle bundle, f f1)
{
    a = account;
    b = bundle;
    c = f1;
    super();
}
 
Example #18
Source File: SyncUtils.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
public void requestSync(String authority, Bundle bundle) {
    Account account = mUser.getAccount();
    Bundle settingsBundle = new Bundle();
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
    if (bundle != null) {
        settingsBundle.putAll(bundle);
    }
    ContentResolver.requestSync(account, authority, settingsBundle);
}
 
Example #19
Source File: SyncStatusHelper.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Checks whether sync is currently enabled from Chrome for a given account.
 *
 * It checks both the master sync for the device, and Chrome sync setting for the given account.
 *
 * @param account the account to check if Chrome sync is enabled on.
 * @return true if sync is on, false otherwise
 */
public boolean isSyncEnabled(Account account) {
    if (account == null) return false;
    boolean returnValue;
    synchronized (mCachedSettings) {
        returnValue = mCachedMasterSyncAutomatically &&
            mCachedSettings.getSyncAutomatically(account);
    }

    notifyObservers();
    return returnValue;
}
 
Example #20
Source File: Accounts.java    From indigenous-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns users.
 *
 * @return User[]
 */
public List<User> getAllUsers() {
    List<User> users = new ArrayList<>();
    AccountManager accountManager = AccountManager.get(context);
    for (Account a : accountManager.getAccountsByType(ACCOUNT_TYPE)) {
        User user = new User();
        user.setAccount(a);
        user.setMe(a.name);
        String token = "";
        try {
            token = accountManager.peekAuthToken(a, IndieAuthActivity.TOKEN_TYPE);
        }
        catch (Exception ignored) {}

        user.setAccessToken(token);
        user.setAvatar(accountManager.getUserData(a, "author_avatar"));
        user.setName(accountManager.getUserData(a, "author_name"));
        user.setTokenEndpoint(accountManager.getUserData(a, "token_endpoint"));
        user.setAuthorizationEndpoint(accountManager.getUserData(a, "authorization_endpoint"));
        user.setMicrosubEndpoint(accountManager.getUserData(a, "microsub_endpoint"));
        user.setMicropubEndpoint(accountManager.getUserData(a, "micropub_endpoint"));
        user.setMicropubMediaEndpoint(accountManager.getUserData(a, "micropub_media_endpoint"));
        user.setSyndicationTargets(accountManager.getUserData(a, "syndication_targets"));
        user.setPostTypes(accountManager.getUserData(a, "post_types"));
        user.setAccount(a);
        users.add(user);
    }
    return users;
}
 
Example #21
Source File: InvalidationGcmUpstreamSender.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void deliverMessage(final String to, final Bundle data) {
    @Nullable
    Account account = ChromeSigninController.get().getSignedInUser();
    if (account == null) {
        // This should never happen, because this code should only be run if a user is
        // signed-in.
        Log.w(TAG, "No signed-in user; cannot send message to data center");
        return;
    }

    final Bundle dataToSend = createDeepCopy(data);
    final Context applicationContext = getApplicationContext();

    // Attempt to retrieve a token for the user.
    OAuth2TokenService.getOAuth2AccessToken(this, account,
            SyncConstants.CHROME_SYNC_OAUTH2_SCOPE,
            new AccountManagerHelper.GetAuthTokenCallback() {
                @Override
                public void tokenAvailable(final String token) {
                    new AsyncTask<Void, Void, Void>() {
                        @Override
                        protected Void doInBackground(Void... voids) {
                            sendUpstreamMessage(to, dataToSend, token, applicationContext);
                            return null;
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }

                @Override
                public void tokenUnavailable(boolean isTransientError) {
                    GcmUma.recordGcmUpstreamHistogram(
                            getApplicationContext(), GcmUma.UMA_UPSTREAM_TOKEN_REQUEST_FAILED);
                }
            });
}
 
Example #22
Source File: WoodminSyncAdapter.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
public static Account getSyncAccount(Context context) {

        String user = Utility.getPreferredUser(context);
        AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
        Account account = new Account("Woodmin", context.getString(R.string.sync_account_type));
        if ( accountManager.getPassword(account) == null  ) {
            String secret = Utility.getPreferredSecret(context);
            if (!accountManager.addAccountExplicitly(account, secret, null)) {
                return null;
            }
            onAccountCreated(account, context);
        }
        return account;

    }
 
Example #23
Source File: EvercamAccount.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
public AppUser retrieveUserDetailFromAccount(Account account) {
    String apiKey = mAccountManager.peekAuthToken(account, KEY_API_KEY);
    String apiId = mAccountManager.peekAuthToken(account, KEY_API_ID);
    String username = mAccountManager.getUserData(account, KEY_USERNAME);
    String country = mAccountManager.getUserData(account, KEY_COUNTRY);
    String firstName = mAccountManager.getUserData(account, KEY_FIRSTNAME);
    String lastName = mAccountManager.getUserData(account, KEY_LASTNAME);
    String intercom_hmac_android = mAccountManager.getUserData(account, KEY_INTERCOM_HMAC);

    String isDefaultString = mAccountManager.getUserData(account, KEY_IS_DEFAULT);

    AppUser appUser = new AppUser();
    appUser.setEmail(account.name);
    appUser.setApiKeyPair(apiKey, apiId);
    appUser.setUsername(username);
    appUser.setCountry(country);
    appUser.setFirstName(firstName);
    appUser.setLastName(lastName);
    appUser.setIntercom_hmac_android(intercom_hmac_android);

    if (isDefaultString != null && isDefaultString.equals(TRUE)) {
        appUser.setIsDefault(true);
        AppData.defaultUser = appUser;
    }

    return appUser;
}
 
Example #24
Source File: OAuth2TokenService.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers a notification to all observers of the native and Java instance of the
 * OAuth2TokenService that a refresh token is now revoked.
 */
@VisibleForTesting
public void fireRefreshTokenRevoked(Account account) {
    ThreadUtils.assertOnUiThread();
    assert account != null;
    nativeFireRefreshTokenRevokedFromJava(
            mNativeOAuth2TokenServiceDelegateAndroid, account.name);
}
 
Example #25
Source File: DataSynchronizer.java    From PhilHackerNews with MIT License 5 votes vote down vote up
@Inject
public DataSynchronizer(Account account,
                        HackerNewsCache hackerNewsCache,
                        @Named(RemoteDataFetcher.DAGGER_INJECT_QUALIFIER) DataFetcher remoteDataFetcher,
                        @Named(CachedDataFetcher.DAGGER_INJECT_QUALIFIER) DataFetcher cachedDataFetcher) {
    mAccount = account;
    mHackerNewsCache = hackerNewsCache;
    mRemoteDataFetcher = remoteDataFetcher;
    mCachedDataFetcher = cachedDataFetcher;
}
 
Example #26
Source File: SyncStatusHelper.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@VisibleForTesting
protected void setSyncAutomaticallyInternal(Account account, boolean value) {
    mSyncAutomatically = value;
    StrictMode.ThreadPolicy oldPolicy = temporarilyAllowDiskWritesAndDiskReads();
    mSyncContentResolverWrapper.setSyncAutomatically(account, mContractAuthority, value);
    StrictMode.setThreadPolicy(oldPolicy);
    mDidUpdate = true;
}
 
Example #27
Source File: Authenticator.java    From cordova-android-accountmanager with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) throws NetworkErrorException
{
    // If the caller requested an authToken type we don't support, then
    // return an error
    /*if(authTokenType isn't a supported auth token type)
    {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType");
        return result;
    }*/

    // Extract the username and password from the Account Manager, and ask
    // the server for an appropriate AuthToken.
    final AccountManager am = AccountManager.get(ctx);
    final String password = am.getPassword(account);
    if (password != null)
    {
        final String authToken = ""; /* TODO: Login with account.name and passwod */
        if (!TextUtils.isEmpty(authToken))
        {
            final Bundle result = new Bundle();
            result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
            result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
            result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
            return result;
        }
    }

    //final Intent intent = null; // TODO: Login intent
    //final Bundle bundle = new Bundle();
    //bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    //return bundle;
    return null;
}
 
Example #28
Source File: PreferencesActivity.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
private void chooseAccount() {
    try {
        if (isRequestingPermissions(this, GET_ACCOUNTS, "android.permission.USE_CREDENTIALS")) {
            return;
        }
        Account selectedAccount = getSelectedAccount();
        Intent intent = AccountPicker.newChooseAccountIntent(selectedAccount, null,
                new String[]{"com.google"}, true, null, null, null, null);
        startActivityForResult(intent, CHOOSE_ACCOUNT);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, R.string.google_drive_account_select_error, Toast.LENGTH_LONG).show();
    }
}
 
Example #29
Source File: ApplicationManager.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        createDatabaseTables();

//        Fabric.with(this, new Crashlytics());
        FirebaseApp.initializeApp(this);

        AccountManager accountManager = AccountManager.get(this);
        Account[] accounts = accountManager.getAccountsByType(Constants.ACCOUNT_TYPE);
        String username = "", password = "";

        if (accounts.length > 0) {
            username = accounts[0].name;
            password = accountManager.getPassword(accounts[0]);
        }

        if (username.length() > 0 && password.length() > 0) {
            userCredentials = new UserCredentials(username, password);
        }

        SecurePreferences securePreferences = new SecurePreferences(this);
        int typeUsagerId = securePreferences.getInt(Constants.TYPE_USAGER_ID, -1);
        String domaine = securePreferences.getString(Constants.DOMAINE, "");

        if(typeUsagerId != -1 && !TextUtils.isEmpty(domaine)) {
            ApplicationManager.typeUsagerId = typeUsagerId;
            ApplicationManager.domaine = domaine;
        }

        appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
    }
 
Example #30
Source File: AuthHelper.java    From android-atleap with Apache License 2.0 5 votes vote down vote up
/**
 * Get last used or first account in the list of accounts.
 * If there are not last used the first account of specified type will be returned.
 * <code>null</code> could be returned if there are not accounts of specified type.
 * @param context context
 * @param accountType account type
 * @return last used account. If there are not last used the first account of specified type will be returned.
 */
public static Account getLastOrFirstAccount(Context context, String accountType) {
    Account account = getLastUsedAccount(context, accountType);
    if (account != null) {
        return account;
    } else {
        return getFirstAccountByType(context, accountType);
    }
}