2011-12-01 1 views
6

Je suis en train de concevoir un écran d'appel personnalisé pour afficher des informations, telles que les informations du carnet d'adresses de l'appelant, à l'écran pendant la conversation téléphonique. Mon application va commencer lorsque l'utilisateur appuie sur le bouton d'appel en utilisant un Intent Filter, après quoi je vais chercher d'autres informations dans le carnet d'adresses et l'ajouter à l'écran.Le filtre d'intention ne fonctionne pas pour l'écran d'appel

Mon problème est que lorsque le bouton d'appel est appuyé, mon activity ne démarre pas. Mon filtre d'intention est-il correct? Est-il même possible d'intercepter l'appel téléphonique Intent? S'il vous plaît partager vos connaissances sur la gestion des événements d'appel. Le numéro Intent Filter est illustré ci-dessous. Dans votre cas

<activity android:name=".MyCallingScreen"> 
    <intent-filter android:priority="100"> 
    <action android:name="android.intent.action.CALL_BUTTON" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:scheme="tel" /> 
    </intent-filter> 
</activity>  

Répondre

4

essayez de changer votre code suivant ainsi:

<intent-filter android:priority="100"> 
    <action android:name="android.intent.action.CALL_BUTTON" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

C'est un travail pour moi si appuyer sur un bouton d'appel.

Essayez d'utiliser le code suivant pour intercepter l'appel:

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

Pour HTC quelques changements là-bas:

<activity> 
    <intent-filter> 
    <action android:name="android.intent.action.CALL_PRIVILEGED" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:mimeType="vnd.android.cursor.item/phone" /> 
    <data android:mimeType="vnd.android.cursor.item/phone_v2" /> 
    <data android:mimeType="vnd.android.cursor.item/person" /> 
    </intent-filter> 
</activity> 

intention avec l'action android.intent.action.CALL_PRIVILEGED est appelée lorsque vous faire un appel à partir du répertoire en suivant la procédure suivante: Répertoire téléphonique-> Contact-> Numéro de téléphone Clic long -> Choisissez appel dans le menu déroulant.

0

Je ne suis pas sûr s'il est possible de remplacer l'écran d'appel, mais il est relativement simple d'intercepter tout appel sortant. Vous déclarez dans votre récepteur manifeste:

 <receiver android:name="com.mystuff.CallInterceptor" android:exported="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> 
     </intent-filter> 
    </receiver> 

et vous faites une classe Java pour cette Interceptor:

public class CallInterceptor extends BroadcastReceiver { 

@Override 
public void onReceive(Context context, Intent intent) { 
     if (!intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) 
     { 
     return; 
     } 
     String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); 
     //do stuff using the number 
     //assuming you do nothing too bad the call will happen and the regular 
     //call screen comes up - but you can bring up another activity on top of it 
     //for example shwing address info 
    } 
}