Make a Call in on number followed by # key

2019-01-29 10:14发布

问题:

I am working on the calling app where I make call on button click but if the number just followed by # then it does not take the # key at the last of phone number.

For Example if I want to make a call on *123# from app then it only shows *123 in the calling screen in phone. Please suggest me where I am going wrong.

Here is my code for call on *123# on button click.

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + phoneNumber));
callIntent.setData(Uri.parse("tel:" + "*123#"));
startActivity(callIntent);

回答1:

try this...

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ Uri.encode("*123#")));
startActivity(callIntent);


回答2:

You need to escape the # as a URI entity: %23