Telephonymanager.EXTRA_INCOMING_NUMBER is deprecated in API level 29

前端 未结 2 501
醉酒成梦
醉酒成梦 2021-01-25 19:06

I am in situation where I need to identify incoming call phone number in Android but when using TelephonyManager.EXTRA_INCOMING_NUMBER android studio wa

2条回答
  •  清歌不尽
    2021-01-25 19:43

    Create a CallScreeningService like this:

    class ScreeningService : CallScreeningService() {
    
        override fun onScreenCall(callDetails: Call.Details) {
            val phoneNumber = callDetails.handle.schemeSpecificPart
            // Do stuff with phone number
        }
    }
    

    And register this service in your AndroidManifest.xml:

    
         
             
         
    
    

提交回复
热议问题