Sending USSD code with alphabetic characters

后端 未结 1 425
盖世英雄少女心
盖世英雄少女心 2021-01-06 23:49

In my android app, I am sending USSD codes (#144#73#) using below Intent :

String baseUssd = Uri.encode(\"#\") + \"144         


        
相关标签:
1条回答
  • 2021-01-07 00:35

    Meaning that the dialer transform this : #144#73MA#

    to this #144#7362# : why ?

    I will try to answer only the why part.

    Intent.ACTION_CALL is handled by OutgoingCallBroadcaster class. If you look at processIntent() method, there is this piece of code (lines 438~448 as of this writing):

    String number = PhoneNumberUtils.getNumberFromIntent(intent, this);
    // Check the number, don't convert for sip uri
    // TODO put uriNumber under PhoneNumberUtils
    if (number != null) {
        if (!PhoneNumberUtils.isUriNumber(number)) {
            number = PhoneNumberUtils.convertKeypadLettersToDigits(number);
            number = PhoneNumberUtils.stripSeparators(number);
        }
    } else {
        Log.w(TAG, "The number obtained from Intent is null.");
    }
    

    There PhoneNumberUtils.convertKeypadLettersToDigits() converts the letters into the equivalent numeric digits:

    public static String convertKeypadLettersToDigits (String input)

    Translates any alphabetic letters (i.e. [A-Za-z]) in the specified phone number into the equivalent numeric digits, according to the phone keypad letter mapping described in ITU E.161 and ISO/IEC 9995-8.

    Returns
    the input string, with alpha letters converted to numeric digits using the phone keypad letter mapping. For example, an input of "1-800-GOOG-411" will return "1-800-4664-411".

    Hope this helps.

    0 讨论(0)
提交回复
热议问题