King Yohel
King Yohel

Reputation: 25

Unicode in java to call

Here below is a sample of my code, so what i am trying to do is to place a call using the number below. when i run the application it shows me sent, then after it places a call to *155 instead of *155#.

Thanks in advance.

String tel = "tel:" + '\u002A' + 155 + '\u0023';
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(tel));
startActivity(callIntent);
Toast.makeText(getApplicationContext(),
"sent " + tel, Toast.LENGTH_LONG).show();

Upvotes: 1

Views: 143

Answers (1)

Flying Swissman
Flying Swissman

Reputation: 803

Replace '\u0023' with "%23". Hashtag is a reserved character and therefore you have to passed in '%'-escaped octets using the UTF-8 scheme.

See RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax for details.

Alternatively you can use the static method of Uri:

Uri.encode("*155#");

and it will do the escaping for you.

Upvotes: 1

Related Questions