2015-02-04 48 views
1

我在這個問題上找到了幾個答案,但它不適合我。如果你在電子郵件或網站上點擊一個電話號碼,默認的撥號器彈出來選擇撥號器/ Skype等意圖'點擊電話號碼'後打開活動

我試圖讓我的應用程序在列表中 - 所以我不想要以處理實際的通話,但打開該活動並顯示用戶點擊的號碼。

我已經試過這樣:

<receiver android:name=".MyOutgoingCallHandler"> 
      <intent-filter> 
       <action android:name="android.intent.action.ACTION_DIAL" /> 
       <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </receiver> 

但它不在列表中顯示。我應該過濾什麼意圖?

回答

0

如果你想一個Activity添加到的將被顯示給用戶儘可能的電話撥號器Activity是清單,你需要有一個Activity<activity>必須包含這個intent-filter>在清單:

<activity ...> 
    <intent-filter> 
     <action android:name="android.intent.action.DIAL" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter> 
</activity> 

你有什麼是BroadcastReceiver將接收呼出Intent。這是不同的。

0

官方Android Developers blog已經涵蓋了這個過程。你可以在那裏閱讀關於它的所有信息

你的意圖過濾器看起來像它有正確的操作,所以它可能是你沒有請求正確的Android權限。

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

這是Android開發者博客如何建議您聲明廣播接收器。

<manifest> 
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 
    <application> 
     ... 
     <receiver android:name=MyOutgoingCallHandler"> 
      <intent-filter> 
       <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </receiver> 
     ... 
    </application> 
</manifest>