Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...