I would like my application to be registered a handler for phone calls via the "Complete action using..." dialog. I've found that it works if I use the following syntax in my manifest:
<activity android:name="my.class">
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</activity>
but if I register it as a broadcast receiver, my app doesn't show up in the "Complete action using..." dialog.
<receiver android:name="my.class">
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</receiver>
What's the difference between the two apart from the type of class that's going to be called once an Intent matches the filter?
An IntentFilter specifies the types of intents to which an activity, service, or broadcast receiver can respond to by declaring the capabilities of a component. BroadcastReceiver does not allows an app to receive video streams from live media sources.
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.
Activity is a UI component which you see on your screen. An Intent is a message object which is used to request an action from the same/different app component.
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.
Difference is clear: the first one will try to launch an Activity
, while the second one will execute a BroadcastReceiver
. What to use depends on what you want to achieve; use BroadcastReceiver
when you want to catch some event but do not want to show anything to the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With