Replacing in call app

前端 未结 2 1321
后悔当初
后悔当初 2020-12-13 14:19

Background

I\'m trying to develop a really simple in call app to replace the stock version. Basically, I just want to answer incoming calls and present the user wi

相关标签:
2条回答
  • 2020-12-13 14:46
    1. Is it even possible for third-party app to replace the default in call app?

    Yes, starting with API 23 it is possible.

    1. Are there any sample implementations using this API out there I may use as a reference? I've found the google implementation, but this is a system app which makes use of some permissions that are not available for other apps (ex: android.permission.MODIFY_PHONE_STATE).

    The only one I'm aware of, is the sample I created https://github.com/arekolek/simple-phone that was already mentioned in the other answer as well.

    1. Am I correct in the assumption that after providing a correct InCallService manifest registration and a stub implementation I could expect to find my app under Default Apps -> Phone? Do I need to declare something else?

    Actually, no.

    Like mentioned in another answer on the topic, you don't need InCallService at all to appear on that list.

    What you need though, is to register an activity with two intent filters, one with a tel Uri scheme, and one with an empty scheme (having just one of them is not enough):

    <intent-filter>
        <action android:name="android.intent.action.DIAL" />
        <data android:scheme="tel" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.DIAL" />
    </intent-filter>
    

    It is vaguely mentioned in the docs, and stated explicitly in AOSP code.

    That is enough to appear on that list. Only then, to provide the UI for the call, will you actually need the InCallService.

    0 讨论(0)
  • 2020-12-13 14:56

    According to the docs and as you comment yourself, you need to add this in your manifest:

    <service android:name="your.package.YourInCallServiceImplementation"
              android:permission="android.permission.BIND_INCALL_SERVICE">
          <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
          <intent-filter>
              <action android:name="android.telecom.InCallService"/>
          </intent-filter>
     </service>
    

    android:name must be replaced by the class that implements this service.


     <activity android:name="your.package.YourDialerActivity">
          <intent-filter>
               <action android:name="android.intent.action.DIAL" />
               <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
     </activity>
    

    android:name must be replaced by the class that implements the main activity for your own dialer implementation.

    Here you can find more information about this: https://developer.android.com/guide/topics/connectivity/telecom/selfManaged

    And here's a sample project that you can use as a guide: https://github.com/arekolek/simple-phone

    And this: https://stackoverflow.com/a/49835987/1916449

    0 讨论(0)
提交回复
热议问题