Generally speaking, in order to know how to override any default Activity, first you need to know the structure of the Intent that can launch the Activity.
Determining the structure of the Intent
- Open Android Monitor (aka Logcat)
- Filter the log to only show those matching the string "ActivityManager"
- Launch the Activity that you want to override. In your case, launch the call screen
If the Activity can be overridden, you should see a log entry with "START...", copy that entry so that you don't lose it in the log. On my device, this entry was:
START u0 {act=android.intent.action.CALL dat=tel:xxxxxxxxxxx flg=0x10000000 cmp=com.android.server.telecom/.CallActivity (has extras)} from uid 10088 on display 0
This Intent is made up of
- act - The Intent action
- dat - The Intent data
- cmp - The Intent component
Now you need to check if this Intent can launch the default dialer without specifying the component.
Checking if a default Activity can be overridden
- adb shell
- am start -a android.intent.action.CALL -d tel:xxxxxxxxxxx (fill in the number you want to test with)
If it launches the dialer, then, voila. You should be able to create an IntentFilter for your application, setting the action and the data appropriately. Then, the next time the user tries to make a call, it will ask the user which app they want to use.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…