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?
Difference is clear: the first one will try to launch an
Activity, while the second one will execute aBroadcastReceiver. What to use depends on what you want to achieve; useBroadcastReceiverwhen you want to catch some event but do not want to show anything to the user.