Intent.ACTION_DIAL 号码以 # 结尾

Kha*_*han 3 android android-intent

因此,我尝试通过Intent.ACTION_DIAL以 # ie 结尾的方式发送一个号码*123#。但是当Android Dialer应用程序启动时,只有*123(#号丢失)。我正在使用以下代码来触发 Android 的拨号应用程序。

Uri number = Uri.parse("tel:*124#");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud)

期待感谢!!。

Boj*_*man 5

您需要对井号标签 (#) 进行正确编码。在您的 URL 请求中,它应该是 %23,因此将其替换为 %23 就可以了。

Uri number = Uri.parse("tel:*124%23");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud)

您还可以让 URI 进行编码:

String encodedPhoneNumber = String.format("tel:%s", Uri.encode("*1234#"));
Uri number = Uri.parse(encodedPhoneNumber);
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud)