Android调用意图用'#'标记为数字,防止Uri.parse删除#

时间:2017-03-28 12:34:20

标签: android android-intent uri

我想用'* 140 * 123456#'或' 141 #123456#'拨打电话号码。但是Uri.parse(phoneNumber)方法会删除所有'#'符号和数字。它是什么解决方案?

4 个答案:

答案 0 :(得分:0)

检查this

应为\u0023

答案 1 :(得分:0)

答案 2 :(得分:0)

我遇到了同样的问题,并通过将字符串中的TypeError: ord() expected string of length 1, but int found 替换为from sys import argv, exit def encode(data): encoded = '' while data: current = data[0] count = 1 for i in data[1:]: if i == current: count += 1 else: break if count == 255: break encoded += '{}{}'.format(chr(ord(current) & 255), chr(count & 255)) #error occurs here. data = data[count:] return encoded if __name__ == '__main__': if len(argv) < 2: print('Please specify input file!') exit(0) with open(argv[1], 'rb') as (f): data = f.read() with open(argv[1] + '.out', 'wb') as (f): f.write(encode(data)) 来解决了这个问题。

答案 3 :(得分:0)

operator = 123
String UssdCodeNew =  "*" + operator + Uri.encode("\u0023");

尝试一下,反抗正常。