本文主要是介绍隐藏帐户,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
操作步骤】:1、打开设置-帐户
2、添加帐户
【测试结果】:添加帐户有sim卡和电话项
【预期结果】:无sim卡相关项
res/values/arrays.xml
<!-- Defined the hide accounts' type -->
<string-array name="hide_account_list">
<item>com.android.localphone</item>
<item>com.android.sim</item>
</string-array>
src/com/android/settings/Utils.java
/**
* Returns if need show the account with the given account type.
*/
public static boolean showAccount(Context context, String accountType) {
String[] hideAccounts = context.getResources().getStringArray(R.array.hide_account_list);
if (hideAccounts == null || hideAccounts.length == 0) return true;
for (String account : hideAccounts) {
if (account.equals(accountType)) return false;
}
return true;
}
src/com/android/settings/accounts/ChooseAccountActivity.java
private void onAuthDescriptionsUpdated() {
// Create list of providers to show on preference screen
// Create list of providers to show on preference screen
for (int i = 0; i < mAuthDescs.length; i++) {
for (int i = 0; i < mAuthDescs.length; i++) {
String accountType = mAuthDescs[i].type;
String accountType = mAuthDescs[i].type;
if (!Utils.showAccount(this, accountType)) {
// If needn't to show the account, skip this account.
continue;
}
这篇关于隐藏帐户的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!