2011-09-02 12 views
8

Ho riscontrato il problema che il segno di hash è stato troncato. Qualcuno conosce una soluzione? l'utilizzo di unicode o% 23 non funziona nel mio caso. Ora il numero da comporre è * 101Invio intento ACTION_CALL in Android contenente il segno hash #

String uri = "tel:" + "*101#"; 

//String uri = "tel:" + "*101\u0023"; 

Intent intent; 
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri)); 

risposta

15

trovato una soluzione: String = encodedHash Uri.encode ("#"); questo ha fatto il trucco ...

+0

Grazie per quello :), buona scoperta. – Warpzit

10

ho trovato una soluzione per questo problema, sostituendo # in% 23

String uri = "tel:" + "*133%23"; 

Intent intent; 
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri)); 
0

Un tutto in una soluzione potrebbe essere:

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

Questo sarebbe più facile ;

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