Waqar Khan
Waqar Khan

Reputation: 478

Intent.ACTION_DIAL with number ending with #

So I'm trying to send a number via Intent.ACTION_DIAL ending with # i.e for example *123#. But when the Android Dialer app is started, there is only *123 (# is missing). I'm using following code to trigger the Dial Application of Android.

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

Anticipated Thanks!! .

Upvotes: 3

Views: 6037

Answers (2)

anj0
anj0

Reputation: 44

The answer could be related with this link initiate a phone call on android with special character #
This line could be the key Uri.parse("tel:"+Uri.encode("*124#"));

Upvotes: 1

Bojan Kseneman
Bojan Kseneman

Reputation: 15668

You need to properly encode the hash tag (#). In your URL requests it should be %23, so replacing it with %23 will do the trick.

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

You can also let URI do the encoding:

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);

Upvotes: 5

Related Questions