2011-09-02 27 views
8

我遇到了散列符號被截斷的問題。有人知道解決方案嗎?使用unicode或%23在我的情況下不起作用。現在撥打的號碼是* 101在Android中發送ACTION_CALL Intent包含散列號#sign

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

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

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

回答

15

找到了解決辦法:String encodedHash = Uri.encode(「#」);這並獲得成功......

+0

謝謝你:),很好找。 – Warpzit

10

我發現這個問題的解決方案通過在更換%#23

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

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

的都在同一個解決方案是:

  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

這會更容易;

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