Example usage for android.telephony PhoneNumberUtils extractNetworkPortion

List of usage examples for android.telephony PhoneNumberUtils extractNetworkPortion

Introduction

In this page you can find the example usage for android.telephony PhoneNumberUtils extractNetworkPortion.

Prototype

public static String extractNetworkPortion(String phoneNumber) 

Source Link

Document

Extracts the network address portion and canonicalizes (filters out separators.) Network address portion is everything up to DTMF control digit separators (pause or wait), but without non-dialable characters.

Usage

From source file:com.android.mms.ui.MessageUtils.java

/** M: Code analyze 022, For fix bug ALPS00281094, Can not send and receive Sms.
 * Return true iff the network portion of <code>address</code> is,
 * as far as we can tell on the device, suitable for use as an SMS
 * destination address./*  w w  w  . j  av  a 2s.c o  m*/
 */
public static boolean isWellFormedSmsAddress(String address) {
    // MTK-START [mtk04070][120104][ALPS00109412]Solve
    // "can't send MMS with MSISDN in international format"
    // Merge from ALPS00089029
    if (!isDialable(address)) {
        return false;
    }
    // MTK-END [mtk04070][120104][ALPS00109412]Solve
    // "can't send MMS with MSISDN in international format"

    String networkPortion = PhoneNumberUtils.extractNetworkPortion(address);

    return (!(networkPortion.equals("+") || TextUtils.isEmpty(networkPortion))) && isDialable(networkPortion);
}