如何以编程方式按DialPad btn?

时间:2019-02-18 07:14:16

标签: android incoming-call

我正在使用Android Oreo,在接听来电时,需要以编程方式在DialPad上按下(或模拟)一些符号。

我有下一个代码,它是自动接听电话:

    override fun onReceive(context: Context, intent: Intent?) {
            if(intent == null || intent.extras == null)
                return

            val stateStr = intent.extras.getString(TelephonyManager.EXTRA_STATE)
            if(stateStr == null || stateStr != TelephonyManager.EXTRA_STATE_RINGING)
                return

            val savedPhone = prefs.getPhoneNumber()
            val number = intent.extras!!.getString(TelephonyManager.EXTRA_INCOMING_NUMBER)

            if (savedPhone != number)
                return

            val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
            telecomManager.acceptRingingCall()
        }

如何按DialPad btn或以编程方式模拟它?

0 个答案:

没有答案