How to change the incoming calling number to the name of the contact i have with an api call?

207 views Asked by At

I'm pretty new to Kotlin and Android. I've been trying to create a Caller ID app.

I've succeeded to make my Api call with the CallScreeningService and to pop a notification to the user with the actual name of the calling person.

The next step for me is to change the calling notification and calling screen number for the name i did get from my Api.

Because i didn't found how to do it with the CallScreeningService I've tried to implement the ConnectionService which it seemed could change everything. My problem is that i couldn't get it working. It seems that the service is never created and never called.

I have a function to register it with the calling manager :

    private fun registerTelecomManager(){
        val telecomManager: TelecomManager = this.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
        val componentName = ComponentName(this, MyConnectionService::class.java)
        val phoneAccountHandle = PhoneAccountHandle(componentName,"Admin")
        val phoneAccount = PhoneAccount.builder(phoneAccountHandle, "Phone label")
            .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED).build()
        telecomManager.registerPhoneAccount(phoneAccount)
    }

And i think that i did ask for the good permissions :

    <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" />
    <service
            android:name="com.orinea.nicoka_callerid.services.MyCallScreeningService"
            android:permission="android.permission.BIND_SCREENING_SERVICE"
            android:exported="true">
            <intent-filter>
                <action android:name="android.telecom.CallScreeningService" />
            </intent-filter>
        </service>
<service
            android:name="com.orinea.nicoka_callerid.services.MyConnectionService"
            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
            android:exported="true">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService" />
            </intent-filter>
        </service>

I was hoping that someone could tell me what i'm missing and how to fix my problem.

Thank you for reading me, have a nice day!

0

There are 0 answers