我的代码是:
x="*141#";
String phoneCallUri =("tel:" + x);
Intent phoneCallIntent = new Intent(Intent.ACTION_DIAL);
phoneCallIntent.setData(Uri.parse(phoneCallUri));
startActivity(phoneCallIntent);
当调用电话功能时,它不使用#只调用* 141。请帮助我提前谢谢
我的代码是:
x="*141#";
String phoneCallUri =("tel:" + x);
Intent phoneCallIntent = new Intent(Intent.ACTION_DIAL);
phoneCallIntent.setData(Uri.parse(phoneCallUri));
startActivity(phoneCallIntent);
当调用电话功能时,它不使用#只调用* 141。请帮助我提前谢谢
您应该将第二行更改为:String phoneCallUri = "tel:" + Uri.encode(x);
#
在 Uri 中具有空间意义,因此您必须对其进行编码。像这样更正:
x="*141#";
String phoneCallUri =("tel:" + Uri.encode(x));
Intent phoneCallIntent = new Intent(Intent.ACTION_DIAL);
phoneCallIntent.setData(Uri.parse(phoneCallUri));
startActivity(phoneCallIntent);
x="*141#";
Uri uri = Uri.fromParts("tel", x, null);
Intent phoneCallIntent = new Intent(Intent.ACTION_DIAL);
phoneCallIntent.setData(uri);
startActivity(phoneCallIntent);