2016-07-08 88 views
0

我正在嘗試撥打包含「#」和「*」號碼的電話。我的問題是 「#」沒有寫在我試圖撥打的電話號碼中。打電話給包含「#」的號碼

例如:打到「* 142#」的電話,它只顯示一個電話「* 142」。

我使用:

Intent i = new Intent() 
     .setAction(Intent.ACTION_CALL) 
     .setData(Uri.parse("tel:*142#")); 
startActivity(i); 

回答

0

試試這個

Uri.parse(String.format("tel:%s", Uri.encode(number))) 
+0

我無法使用它! ,爲什麼? –

+0

我需要更多信息。你是什​​麼意思,你不能使用它? – BR89

+0

檢查這個線程http://stackoverflow.com/questions/4815785/initiate-a-phone-call-on-android-with-special-character – BR89

1

你的問題是因爲#是URI的特殊字符。爲了解決這個問題,你需要使用URI.encode進行編碼。看看並嘗試以下內容:

Intent i = new Intent() 
      .setAction(Intent.ACTION_CALL) 
      .setData(URI.parse("tel:" + URI.encode("*142#")); 
startActivity(i); 
相關問題