在我的Android应用程序,我送 USSD
codeS(#144#73#
)使用下面意图
:
字符串baseUssd = Uri.en code(#)+144+ Uri.en code(#);
StringBuilder的建设者=新的StringBuilder();
builder.append(baseUssd);
builder.append(73);
builder.append(Uri.en code(#));
意向意图=新的意图(Intent.ACTION_CALL,Uri.parse(电话:+ builder.toString()));
它运作良好。
我现在想的是发送此code:
#144#73MA#
我运行这个使用拨号盘,继 操作USSD菜单 的,即工作。
但是,如果我尝试这样做的的编程的使用上述意图
,没有工作。
我知道,输入code与拨号键盘时字母不能使用,但我虽然,它可以是可以通过编程!!
任何想法请!
修改
当我尝试以编程方式发送的: #144#73MA#
我注意到,拨号应用程序更改字母其对应的< STRONG>数字在拨号盘。这意味着拨号器转换这样的: #144#73MA#
本#144#73
62
#
:为什么?
由于:
的 M
相匹配的数字 6
的 A
相匹配的数字 2
解决方案
含义拨号器转换这样的: #144#73MA#
本#144#73
62
#
:为什么?
我会尽量回答只有在为什么部分。
Intent.ACTION_CALL
是 OutgoingCallBroadcaster
类。如果你看看 processIntent()
的方法,还有这片code(线438〜448在撰写本文时):
串号= PhoneNumberUtils.getNumberFromIntent(意向,这一点);
//检查的数量,不转换为SIP URI
// TODO把uriNumber下PhoneNumberUtils
如果(数字!= NULL){
如果(!PhoneNumberUtils.isUriNumber(编号)){
数= PhoneNumberUtils.convertKeypadLettersToDigits(数);
数= PhoneNumberUtils.stripSeparators(数);
}
} 其他 {
Log.w(TAG,从意图获得的号码为空。);
}
有 PhoneNumberUtils.convertKeypadLettersToDigits()
字母转换成等价的数字位数:
公共静态字符串 convertKeypadLettersToDigits (字符串输入)
平移任何字母(即[A-ZA-Z])中指定的电话号码成等价的数字组成,按照ITU E.161和ISO / IEC 9995-8描述的手机键盘字母映射。
返回 输入字符串,与阿尔法字母转换为数字使用手机键盘字母映射位。例如,1-800-GOOG-411的输入将返回1-800-4664-411。
希望这有助于。
In my android app, I am sending USSD
codes (#144#73#
) using below Intent
:
String baseUssd = Uri.encode("#") + "144" + Uri.encode("#");
StringBuilder builder = new StringBuilder();
builder.append(baseUssd);
builder.append("73");
builder.append(Uri.encode("#"));
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + builder.toString()));
It's working well.
What I want now is to send this code :
#144#73MA#
I run this using the dial pad, following the Operator USSD menu, that worked.
But if I try to do this programmatically using the above Intent
that didn't work.
I know that alphabetic characters can't be used when typing code with the Dial Pad, but I though that It can be possible programmatically !!
Any Idea please !
Edit
When I try to send this programmatically : #144#73MA#
I noticed that the Dialer application changes the alphabetic characters to their corresponding digit in the dial pad. Meaning that the dialer transform this : #144#73MA#
to this #144#73
62
#
: why ?
Because :
theM
matches the digit 6
the A
matches the digit 2
解决方案
Meaning that the dialer transform this : #144#73MA#
to this #144#73
62
#
: 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.