1

I am using Android Oreo and I need to press (or simulate if possible) some symbol on dialPad programmatically when pickedUp incoming call.

I have next code, which is pickUp phone call automatically:

    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()
        }

How can i press dialPad btn or simulate it programmatically?

Andriy Antonov
  • 1,360
  • 2
  • 15
  • 29
  • I don't think it is possible to press the dial pad programmatically, as if it was possible, you could enter and execute USSD queries, which could for example transfer money from user's account. – Vladyslav Matviienko Feb 18 '19 at 07:38
  • you can easily execute USSD queries: https://stackoverflow.com/questions/17317981/make-ussd-call-in-android/33185775 – Andriy Antonov Feb 18 '19 at 07:45
  • that won't execute USSD query, it only will open the dealer with pre-filled phone number – Vladyslav Matviienko Feb 18 '19 at 07:47
  • ha-ha :) If your app has "call_phone"permission - it will be executed ;-) just tried! – Andriy Antonov Feb 18 '19 at 07:49
  • ok, looks like that, but still - you can't simulate clicks on other app (without root rights) – Vladyslav Matviienko Feb 18 '19 at 07:51
  • sometimes you can: send intent for example can simulate some actions for some apps. and I am looking exactly for such kind of suggestion. or any other type of simulate: right now I found *telecomManager.sendMmi()* but it needed system permission – Andriy Antonov Feb 18 '19 at 07:56

0 Answers0