如何发送包含小数点浮点(.)的USSD代码? [英] How to send a USSD code containing decimal floating point (.)?

查看:135
本文介绍了如何发送包含小数点浮点(.)的USSD代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发送一个包含双精度值的USSD代码,该值代表要转移的余额帐户金额.该值由整数,可选的小数点分隔符和另外2位数字组成.我的代码如下:

I need to send a USSD code containing a double value, that represents the balance account amount to be transferred. This value is composed by an integer number, and optionally a decimal separator and 2 more digits. My code looks as follows:

    double doubleValue = 0.70;
    String phoneNumber = "51234567", pincode = "1234";
    String ast = Uri.encode("*");
    String baseUssd = ast + "234" + ast + "1" + ast + phoneNumber + ast + pincode + ast;
    StringBuilder builder = new StringBuilder();
    builder.append(baseUssd);
    builder.append(doubleValue); //i.e: 1.35, 0.80
    builder.append(Uri.encode("#"));
    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + builder.toString()));
    startActivity(intent);

我的手机将doubleValue视为135、080等,而忽略了点分隔符.我希望最终的代码包含点",允许发送十进制值.有人解决了这个问题吗?

My phone treats the doubleValue as 135, 080, etc. ignoring the dot separator character. I hope the final code includes "dot", allowing send the decimal value. Someone solved this problem?

推荐答案

考虑我的银行向我发送的密码键盘的工作方式,您必须始终在小数点后两位和显示屏上的格式输入处理点的位置.

Thinking about the way the pinpad, which my bank sent me, works, you always have to enter the two digits after the decimal point and the formatting on the display deals with the position of the point.

因此,如果我输入"1",它将被解释为0.01. 同样,"1023"为10.23.

So if i enter "1", it is interpreted as 0.01. Similarly "1023" would be 10.23.

我认为相同的方法可能对您有效. 因此,将1.23输入为"123",将0.80输入为"80"

I think the same approach could work nicely for you. So 1.23 is entered as "123" and 0.80 as "80"

我看不到将字符限制为0-9#*的参考,但是所有示例都遵循这种格式.但是,您的示例以* 234开头,这似乎符合规范中的该规则

I can't see a reference that limits the characters to 0-9#* but all the examples follow this format. However, your example starts *234, which seems to fit this rule in the specification

情况a)集合(*,#)中的1位,2位或3位数字,后跟1X(Y),其中X =任何数字0-4,Y =任何数字 0-9,然后,可选地为"*,后跟任意数量的任何字符",并以#SEND结尾: 这种情况保留给HPLMN使用.当服务网络从 访问订户,它将直接将USSD消息传递给HPLMN.如果它从 本地用户,由网络决定是本地处理还是将其传递给HLR

Case a) 1, 2 or 3 digits from the set (*, #) followed by 1X(Y), where X=any number 0-4, Y=any number 0-9, then, optionally "* followed by any number of any characters", and concluding with # SEND: This case is reserved for HPLMN use. When a serving network receives such a message from a visiting subscriber, it shall pass the USSD message directly to the HPLMN. If it receives it from a home subscriber, it is up to the network to decide whether to treat it locally or to pass it to the HLR

http://www.etsi.org/delivery/etsi_ts/100600_100699/100625/07.00.00_60/ts_100625v070000p.pdf

通常,我不确定HPLMN(本地公共陆地移动网络)或HLR(本地位置寄存器)是否会期望额外的字符,即使USSD协议中允许整个字符集甚至其他字符集也是如此.

In general, I am not sure the HPLMN (Home Public Land Mobile Network) or HLR (Home Location Register) would expect the extra characters, even though the whole character set and even other character sets are allowed in the USSD protocol.

这篇关于如何发送包含小数点浮点(.)的USSD代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆