Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

android - How to override default call screen?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...