Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 怎麼去掉聯系人、通話記錄、撥號列表界面中的電話號碼中間的空格?

Android 怎麼去掉聯系人、通話記錄、撥號列表界面中的電話號碼中間的空格?

編輯:關於Android編程

 

 

怎麼去掉聯系人、通話記錄、撥號列表界面中的電話號碼中間的空格? 去掉空格也就是去掉號碼格式化,對所有的號碼串將不進行號碼格式化。 1. 注解掉格式化處理
FILE: PhoneNumberFormatter.java
PATH: alps/packages/apps/contacts/src/com/android/contacts/Util
---------------------------------------------------------------------------------------------------------------------------
public static final void setPhoneNumberFormattingTextWatcher(Context context,
TextView textView, Handler handler) {
// Deleted
// new TextWatcherLoadAsyncTask(ContactsUtils.getCurrentCountryIso(context), textView, handler)
// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
// End
} 2. 注解調用Formater的一行代碼
FILE: PhoneNumberFormattingTextWatcher.java
PATH: alps/frameworks/base/telephony/java/android/Telephony
---------------------------------------------------------------------------------------------------------------------------
public PhoneNumberFormattingTextWatcher(String countryCode) {
/** M: Get test mode from SystemProperties, mtk04070, 2012.02.06 */
getTestMode();
if (countryCode == null) throw new IllegalArgumentException();
// mFormatter = PhoneNumberUtil.getInstance().getAsYouTypeFormatter(countryCode);
}
3. 修改formatNumber方法直接返回原始號碼,不會其進行格式化 FILE: PhoneNumberUtils.java
PATH: alps/frameworks/base/telephony/java/android/Telephony
---------------------------------------------------------------------------------------------------------------------------
/**
* Format a phone number.
*


* If the given number doesn't have the country code, the phone will be
* formatted to the default country's convention.
*
* @param phoneNumber
* the number to be formatted.
* @param defaultCountryIso
* the ISO 3166-1 two letters country code whose convention will
* be used if the given number doesn't have the country code.
* @return the formatted number, or null if the given number is not valid.
*
* @hide
*/
public static String formatNumber(String phoneNumber, String defaultCountryIso) { // Before modified
// // Do not attempt to format numbers that start with a hash or star symbol.
// if (phoneNumber.startsWith(#) || phoneNumber.startsWith(*)) {
// return phoneNumber;
// } // PhoneNumberUtil util = PhoneNumberUtil.getInstance();
// String result = null;
// try {
// PhoneNumber pn = util.parseAndKeepRawInput(phoneNumber, defaultCountryIso);
// result = util.formatInOriginalFormat(pn, defaultCountryIso);
// } catch (NumberParseException e) {
// }
// return result; // After modified
return phoneNumber; // Just return, don't format the phoneNumber
} 4. 去掉導入號碼時的格式化處理代碼 FILE: AbstractStartSIMService.java
PATH: alps/packages/apps/contacts/src/com/mediatek/contacts/Simcontact (1) 去掉 actuallyImportOneSimContact() 方法中對 phoneNumber 的格式化處理代碼 :
---------------------------------------------------------------------------------------------------------------------------
/*
* Bug Fix by Mediatek Begin. Original Android's code: xxx
* CR ID: ALPS00289127 Descriptions:
*/
Log.i(TAG, [actuallyImportOneSimContact] phoneNumber before : + phoneNumber);
// AsYouTypeFormatter mFormatter = PhoneNumberUtil.getInstance()
// .getAsYouTypeFormatter(countryCode);
// char[] cha = phoneNumber.toCharArray();
// int ii = cha.length;
// for (int num = 0; num < ii; num++) {
// phoneNumber = mFormatter.inputDigit(cha[num]);
// }
Log.i(TAG, [actuallyImportOneSimContact] phoneNumber after : + phoneNumber);
/*
* Bug Fix by Mediatek End.
*/ (2) 去掉 actuallyImportOneSimContact() 方法中對 additionalNumber 的格式化處理代碼:
---------------------------------------------------------------------------------------------------------------------------
/*
* Bug Fix by Mediatek Begin. Original Android's code:
* xxx CR ID: ALPS00289127 Descriptions:
*/
Log.i(TAG, [actuallyImportOneSimContact] additionalNumber before :
+ additionalNumber);
// AsYouTypeFormatter mFormatter = PhoneNumberUtil.getInstance()
// .getAsYouTypeFormatter(countryCode);
// char[] cha = additionalNumber.toCharArray();
// int ii = cha.length;
// for (int num = 0; num < ii; num++) {
// additionalNumber = mFormatter.inputDigit(cha[num]);
// }
Log.i(TAG, [actuallyImportOneSimContact] additionalNumber after :
+ additionalNumber);
/*
* Bug Fix by Mediatek End.
*/
--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved