1

I have a problem. I convert a string to Uri but it doesn't passes it all.

String num = "*#123#";
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:" + num));
startActivity(call);

After parse it I get ' * ' instead of " *#123# ".

1 Answer 1

1

# is not well recognized in Uri, but you can replace sharp by it's uri representation %23 :

String num = "*%23123%23";

Or, you can do (better but a little more complicated) :

String num = "*".concat(Uri.encode("#")).concat("123").concat(Uri.encode("#"))
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks man! Can you tell me where can I learn more about that?
You can read the URL Encoding reference from W3School : w3schools.com/tags/ref_urlencode.asp
Nice! Thanks, you were very helpful!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.