Search in sources :

Example 1 with Account

use of android.accounts.Account in project Launcher3 by chislon.

the class LauncherTransitionable method skipCustomClingIfNoAccounts.

private boolean skipCustomClingIfNoAccounts() {
    Cling cling = (Cling) findViewById(R.id.workspace_cling);
    boolean customCling = cling.getDrawIdentifier().equals("workspace_custom");
    if (customCling) {
        AccountManager am = AccountManager.get(this);
        if (am == null)
            return false;
        Account[] accounts = am.getAccountsByType("com.google");
        return accounts.length == 0;
    }
    return false;
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager)

Example 2 with Account

use of android.accounts.Account in project philm by chrisbanes.

the class AndroidAccountManager method removeAccount.

@Override
public void removeAccount(PhilmAccount philmAccount) {
    Account account = new Account(philmAccount.getAccountName(), Constants.TRAKT_ACCOUNT_TYPE);
    mAccountManager.removeAccount(account, null, null);
}
Also used : Account(android.accounts.Account) PhilmAccount(app.philm.in.model.PhilmAccount)

Example 3 with Account

use of android.accounts.Account in project philm by chrisbanes.

the class AndroidAccountManager method getAccounts.

@Override
public List<PhilmAccount> getAccounts() {
    final Account[] accounts = mAccountManager.getAccountsByType(Constants.TRAKT_ACCOUNT_TYPE);
    ArrayList<PhilmAccount> philmAccounts = new ArrayList<>(accounts.length);
    for (int i = 0; i < accounts.length; i++) {
        final Account account = accounts[i];
        String password = mAccountManager.getPassword(account);
        philmAccounts.add(new PhilmAccount(account.name, password));
    }
    return philmAccounts;
}
Also used : Account(android.accounts.Account) PhilmAccount(app.philm.in.model.PhilmAccount) ArrayList(java.util.ArrayList) PhilmAccount(app.philm.in.model.PhilmAccount)

Example 4 with Account

use of android.accounts.Account in project android_frameworks_base by ParanoidAndroid.

the class BugreportReceiver method findSendToAccount.

/**
     * Find the best matching {@link Account} based on build properties.
     */
private static Account findSendToAccount(Context context) {
    final AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
    String preferredDomain = SystemProperties.get("sendbug.preferred.domain");
    if (!preferredDomain.startsWith("@")) {
        preferredDomain = "@" + preferredDomain;
    }
    final Account[] accounts = am.getAccounts();
    Account foundAccount = null;
    for (Account account : accounts) {
        if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
            if (!preferredDomain.isEmpty()) {
                // looking
                if (account.name.endsWith(preferredDomain)) {
                    return account;
                } else {
                    foundAccount = account;
                }
            // if we don't have a preferred domain, just return since it looks like
            // an email address
            } else {
                return account;
            }
        }
    }
    return foundAccount;
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager)

Example 5 with Account

use of android.accounts.Account in project android_frameworks_base by ParanoidAndroid.

the class BugreportReceiver method buildSendIntent.

/**
     * Build {@link Intent} that can be used to share the given bugreport.
     */
private static Intent buildSendIntent(Context context, Uri bugreportUri, Uri screenshotUri) {
    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("application/vnd.android.bugreport");
    intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment());
    intent.putExtra(Intent.EXTRA_TEXT, SystemProperties.get("ro.build.description"));
    final ArrayList<Uri> attachments = Lists.newArrayList(bugreportUri, screenshotUri);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
    final Account sendToAccount = findSendToAccount(context);
    if (sendToAccount != null) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { sendToAccount.name });
    }
    return intent;
}
Also used : Account(android.accounts.Account) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Uri(android.net.Uri)

Aggregations

Account (android.accounts.Account)548 Bundle (android.os.Bundle)108 AccountManager (android.accounts.AccountManager)78 Test (org.junit.Test)53 ArrayList (java.util.ArrayList)49 Intent (android.content.Intent)40 File (java.io.File)37 Cursor (android.database.Cursor)31 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)29 PersistableBundle (android.os.PersistableBundle)27 UserInfo (android.content.pm.UserInfo)22 MockContentResolver (android.test.mock.MockContentResolver)22 HashMap (java.util.HashMap)20 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)20 RemoteException (android.os.RemoteException)19 FileOutputStream (java.io.FileOutputStream)19 IOException (java.io.IOException)19 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 HashSet (java.util.HashSet)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16