Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 保存手機郵件中的郵箱地址到聯系人,郵箱地址丟失的問題

android 保存手機郵件中的郵箱地址到聯系人,郵箱地址丟失的問題

編輯:關於Android編程

1.手機插入普通SIM卡
2.登錄郵箱並添加郵箱地址到SIM卡中;
3.發現郵箱地址沒有添加進入,只添加進了姓名或電話號碼
這是Google Default行為,在保存時,會進行安全檢查,發現有不合法的字段時會自動過濾掉該字段。
對於Sim卡,不支持Email字段,所以會過濾掉該字段。

如果不想要這樣的行為,想修改為當發現保存的內容中有Email字段,就不顯示出SIM帳號,可按如下方式修改。

一共需要修改3個文件:

1. com.android.contacts.editor.ContactEditorFragment

找到Intent intent = new Intent(mContext, ContactEditorAccountsChangedActivity.class);
在其下面添加一行:intent.putExtra("data", mIntentExtras);

2.com.android.contacts.activities.ContactEditorAccountsChangedActivity

找到mAccountListAdapter = new AccountsListAdapter(this, AccountListFilter.ACCOUNTS_CONTACT_WRITABLE);
在其下面添加一行:mAccountListAdapter.filterAccountWithBundle(getIntent().getBundleExtra("data"));

3.com.android.contacts.util.AccountsListAdapter
在該文件中添加這個方法:
public void filterAccountWithBundle(Bundle bundle){
if(bundle == null){
return;
}
String email = bundle.getString("email");
if(!TextUtils.isEmpty(email)){
int count = getCount();
for (int i = count - 1; i >= 0; i--) {
if (mAccounts.get(i).type.equals("SIM Account")) {
mAccounts.remove(i);
}
}
}
}
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved