您的位置:首页 > 移动开发 > Android开发

Android中Telephony学习笔记(9)-Phone相关类

2014-05-10 13:14 375 查看

PhoneNumberUtils

提供多种方法工具处理电话号码字符串,工具类。

Constants

FORMAT_JAPAN:日本区号列表

FORMAT_NANP:北美洲电话区号列表

FORMAT_UNKNOWN:未知地区

PAUSE

TOA_International

TOA_Unknown

WAIT

WILD

Methods

public static String calledPartyBCDFragmentToString(byte[] bytes, int offset, int length)

public static String calledPartyBCDToString(byte[] bytes, int offset, int length)

public static boolean compare(String a, String b)

public static boolean compare(Context context, String a, String b)

public static String convertKeypadLettersToDigits(String input)

public static String extractNetworkPortion(String phoneNumber)

public static String extractPostDialPortion(String phoneNumber)

public static void formatJapaneseNumber(Editable text)

public static void formatNanpNumber(Editable text)

public static String formatNumber(String source)

public static void formatNumber(Editable text, int defaultFormattingType)

public static int getFormatTypeForLocale(Locale locale)

public static String getNumberFromIntent(Intent intent, Context context)

public static String getStrippedReversed(String phoneNumber)

public static final boolean
isDialable (char c)

public static boolean isEmergencyNumber(String number)

public static boolean isGlobalPhoneNumber(String phoneNumber)

public static boolean isISODigit(char c)

public static final boolean
isNonSeparator (char c)

public static final boolean
isReallyDialable (char c)

public static final boolean
isStartsPostDial (char c)

public static boolean isWellFormedSmsAddress(String address)

public static byte[] networkPortionToCalledPartyBCD(String s)

public static byte[] networkPortionToCalledPartyBCDWithLength(String s)

public static byte[] numberToCalledPartyBCD(String number)

public static String stringFromStringAndTOA(String s, int TOA)

public static String stripSeparators(String phoneNumber)

public static String toCallerIDMinMatch(String phoneNumber)

public static int toaFromString(String s)

对字符串各种操作,提取到所需要的信息。不做具体解释了。

PhoneNumberFormattingTextWatcher

观察TextView和输入手机号码时,该类提供监听,严格规范手机号码的格式。当用户输入无效的字符,或者删除字符串中间的分隔符该格式化watcher就停止工作。

Methods

public synchronized void afterTextChanged(Editable s)

改变后调用该方法,在Editable内部中,当text文本值改变后是调用该回调

public void beforeTextChanged(CharSequence s, int start, int count, int after)

该回调方法会在改变之前通知你charSequence对象会在第start位置用after长度的字符序列替换当前对象的count个数的字符

public void onTextChanged(CharSequence s, int start, int before, int count)

改变中调用该回调方

PhoneStateListener

监听类,监听手机状态的改变。信号强度,语音信息等。通过TelephonyManager.Listen()给手机添加该监听器。

Constants

LISTEN_CALL_FORWARDING_INDICATOR:呼叫转移的状态改变

LISTEN_CALL_STATE:通话状态的改变

LISTEN_CELL_INFO:信元信息的改变

LISTEN_CELL_LOCATION:信元位置的改变,每隔一段时间返回一次。

LISTEN_DATA_ACTIVITY:数据连接中数据流量的方位改变

LISTEN_DATA_CONNECTION_STATE:数据连接状态的改变

LISTEN_MESSAGE_WAITING_INDICATOR:信息等待显示的改变

LISTEN_NONE:停止监听器的更新

LISTEN_SERVICE_STATE:网络服务状态的改变

LISTEN_SIGNAL_STRENGTH:废弃

LISTEN_SIGNAL_STRENGTHS:网络信号强度的改变

Methods

public void onCallForwardingIndicatorChanged(boolean cfi)

呼叫转移状态改变的回调方法

public void onCallStateChanged(int state, String incomingNumber)

监听通话状态的改变的回调方法

public void onCellInfoChanged(List<CellInfo> cellInfo)

监听信元信息改变的回调方法

public void onCellLocationChanged(CellLocation location)

监听设备位置信息改变的回调方法

public void onDataActivity(int direction)

监听数据活动状态改变的回调方法

public void onDataConnectionStateChanged(int state)

监听数据连接状态改变的回调方法

public void onDataConnectionStateChanged(int state, int networkType)

同上,但是还监听网络类型的改变

public void onMessageWaitingIndicatorChanged(boolean mwi)

监听信息等待显示信息改变的回调方法

public void onServiceStateChanged(ServiceState serviceState)

监听设备服务状态改变的回调方法

public void onSignalStrengthChanged(int asu)

已废弃

public void onSignalStrengthsChanged(SignalStrength signalStrength)

监听信号强度改变的回调方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: