2016-06-07 69 views
-1

有一個應用程序帶有一個按鈕,當按下時使用startActivity方法和ACTION_CALL意圖。意圖ACTION_CALL沒有被我的應用程序截獲

這是它怎麼叫:

public void call(String number) 
{ 
    Intent myIntent = new Intent(Intent.ACTION_CALL); 
    myIntent.setData(Uri.parse("tel:" + number); 
    startActivity(myIntent); 
} 

我已與權限的撥號應用程式:

<uses-permission android:name="android.permission.CALL_PHONE" /> 

我的清單看起來是這樣的:

<intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 
<intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <action android:name="android.intent.action.DIAL" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <data android:scheme="tel" /> 
</intent-filter> 
<intent-filter> 
    <action android:name="android.intent.action.CALL_BUTTON" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

每隔我所看到的問題是建議在清單中做出確切的聲明。

我檢查過,手機附帶的Google撥號器應用程序沒有設置默認設置。

那麼,爲什麼不彈出一個對話框顯示一個選項來選擇我的應用程序作爲撥號程序來捕捉該意圖?

+0

你面臨什麼問題? –

+0

我在問題中寫道:爲什麼不彈出對話框顯示一個選項來選擇我的應用程序作爲撥號程序來捕獲該意圖? –

+0

你可以分享你的android代碼調用嗎?這可能會有所幫助 –

回答

0

我終於搞定了。 加入一些意圖過濾後它開始工作:

<intent-filter> 
      <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 

      <action android:name="android.intent.action.CALL" /> 
      <action android:name="android.intent.action.CALL_BUTTON" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="tel" /> 

     </intent-filter> 

     <intent-filter android:priority="100" > 

      <action android:name="android.intent.action.DIAL" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="tel" /> 

     </intent-filter> 

     <intent-filter> 

      <action android:name="android.intent.action.CALL_BUTTON" /> 
      <category android:name="android.intent.category.DEFAULT" /> 

     </intent-filter> 

     <intent-filter> 

      <action android:name="android.intent.action.CALL_PRIVILEGED" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="tel" /> 

     </intent-filter> 

     <intent-filter> 

      <action android:name="android.intent.action.VIEW" /> 
      <action android:name="android.intent.action.DIAL" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data android:scheme="tel" /> 

     </intent-filter> 

我第一個想到的那樣神奇。

相關問題