Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent Filter for android.intent.action.CALL

Tags:

android

I have an intent filter that looks like so:

<activity
    android:name="com.test.Call"
    android:label="@string/makeCall" >
    <intent-filter>
        <action android:name="android.intent.action.CALL" />
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.CALL_PRIVILEGED" />
        <data android:scheme="tel" />
    </intent-filter>
</activity>

This works fine and when you try to make a call my text appears as one of the options. What I want to do is process the number being called and ask the user some questions and then continue on with the call. I do this by running the following code after I do whatever processing I have do do:

Uri phoneCall = Uri.parse("tel:"  + numToCall);
Intent caller = new Intent(Intent.ACTION_DIAL, phoneCall);
startActivity(caller);

The issue is, it is displaying the same options from the beginning again (the native caller and my intent filter). This is not what I want, I want to bypass my intent filter and go directly to the native caller. Is there a way to do this? How can I force the intent to go directly to the native caller? I am looking at moving this to a broadcast receiver but would rather go this route.

Thanks

like image 869
devo Avatar asked Nov 04 '11 01:11

devo


People also ask

What is action in intent filter?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

What is the difference between intent and intent filter?

An intent is an object that can hold the os or other app activity and its data in uri form.It is started using startActivity(intent-obj).. \n whereas IntentFilter can fetch activity information on os or other app activities.

How does intent filter work in Android?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.


1 Answers

You could try disabling your component via PackageManager.setComponentEnabledSetting() [use the DONT_KILL_APP flags!], but you'll need to re-enable the component again before the next call.

Or you could take Huang's comment above but find out components that catch the ACTION_CALL intent and build your own chooser if there's more than one other than you - use PackageManager.queryIntentActivities() to get a list of Activities.

Using the broadcast is really the right way to go.

like image 99
Philip Pearl Avatar answered Nov 15 '22 11:11

Philip Pearl