androidbuttonclickphone-callnumeric-keypad

How to open number dialer pad programmatically in android?


I want to display Number Dial Keypad (Phone Call) Programmatically on button click in android. Code is available for direct number dialing but I only need to show the dial keypad when I click the Button.


Solution

  • You can use this code if you want to open the dialer programmatically without any number inserted:

    Java

    Intent intent = new Intent(Intent.ACTION_DIAL);
    startActivity(intent);
    

    Kotlin

    val intent = Intent(Intent.ACTION_DIAL)
    startActivity(intent)
    

    If you need to open the dialer with the number already digited you can use this code:

    Java

    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:123 456789"));
    startActivity(intent);
    

    Kotlin

    val intent = Intent(Intent.ACTION_DIAL)
    intent.data = Uri.parse("tel:123 456789")
    startActivity(intent)