Closed shaikhsiddik closed 4 years ago
Finally solve this problem check out this code work for me
if(intent?.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) == true) { val number = intent.extras?.getString(TelephonyManager.EXTRA_INCOMING_NUMBER) if (intent.action == CallRecordReceiver.ACTION_OUT) { Log.d(TAG, "intent.action = outgoing") savedNumber = intent.extras?.getString(CallRecordReceiver.EXTRA_PHONE_NUMBER) } else { Log.d(TAG, "intent.action = InComing") val stateStr = intent.extras?.getString(TelephonyManager.EXTRA_STATE) savedNumber = intent.extras?.getString(TelephonyManager.EXTRA_INCOMING_NUMBER) var state = 0 when (stateStr) { TelephonyManager.EXTRA_STATE_IDLE -> state = TelephonyManager.CALL_STATE_IDLE TelephonyManager.EXTRA_STATE_OFFHOOK -> state = TelephonyManager.CALL_STATE_OFFHOOK TelephonyManager.EXTRA_STATE_RINGING -> state = TelephonyManager.CALL_STATE_RINGING } onCallStateChanged(context, state, savedNumber)
} }
Finally solve this problem check out this code work for me
if(intent?.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) == true) { val number = intent.extras?.getString(TelephonyManager.EXTRA_INCOMING_NUMBER) if (intent.action == CallRecordReceiver.ACTION_OUT) { Log.d(TAG, "intent.action = outgoing") savedNumber = intent.extras?.getString(CallRecordReceiver.EXTRA_PHONE_NUMBER) } else { Log.d(TAG, "intent.action = InComing") val stateStr = intent.extras?.getString(TelephonyManager.EXTRA_STATE) savedNumber = intent.extras?.getString(TelephonyManager.EXTRA_INCOMING_NUMBER) var state = 0 when (stateStr) { TelephonyManager.EXTRA_STATE_IDLE -> state = TelephonyManager.CALL_STATE_IDLE TelephonyManager.EXTRA_STATE_OFFHOOK -> state = TelephonyManager.CALL_STATE_OFFHOOK TelephonyManager.EXTRA_STATE_RINGING -> state = TelephonyManager.CALL_STATE_RINGING } onCallStateChanged(context, state, savedNumber)