Sending ACTION_CALL Intent in Android with hash #

I have a problem with the hash sign truncated. Does anyone know a solution? using unicode or% 23 does not work in my case. Now dialed number - 101

String uri = "tel:" + "*101#"; //String uri = "tel:" + "*101\u0023"; Intent intent; intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri)); 
+8
android android-intent
source share
4 answers

Solution found: String encodedHash = Uri.encode ("#"); it did the trick ...

+15
source share

I found a solution for this problem by replacing # in% 23

 String uri = "tel:" + "*133%23"; Intent intent; intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri)); 
+10
source share

That would be easier:

 String no = textview.getText().toString(); if(no.contains("#")){ no = no.replace("#","%23"); } startActivity(new Intent(Intent.ACTION_CALL) .setData(Uri.parse("tel:" no))); 
+1
source share

All in one solution:

  String number = "*123#"; number = number.replace("*", Uri.encode("*")).replace("#",Uri.encode("#")); Intent mIntent = new Intent(Intent.ACTION_CALL); Uri data = Uri.parse("tel:" + number); mIntent.setData(data); startActivity(mIntent); 
0
source share

All Articles