How to override default call screen?

情到浓时终转凉″ 提交于 2019-12-14 03:34:21

问题


I want to launch my customized screen when user dials any number from my android app instead of default caller screen.


回答1:


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

  1. Open Android Monitor (aka Logcat)
  2. Filter the log to only show those matching the string "ActivityManager"
  3. 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

  1. adb shell
  2. 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.



来源:https://stackoverflow.com/questions/40888058/how-to-override-default-call-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!