How to open number dialer pad programmatically in android?

前端 未结 8 667
执笔经年
执笔经年 2021-02-07 04:10

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 keypa

相关标签:
8条回答
  • 2021-02-07 04:42
    Intent intent =  new Intent(Intent.ACTION_CALL_BUTTON);
    startActivity(intent);
    

    it will show Dial Window check here for information

    0 讨论(0)
  • 2021-02-07 04:42
    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    callIntent.setData(Uri.parse("tel:" + phoneNumber));
     if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                    // TODO: Consider calling
                    //    ActivityCompat#requestPermissions
                    // here to request the missing permissions, and then overriding
                    //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                    //                                          int[] grantResults)
                    // to handle the case where the user grants the permission. See the documentation
                    // for ActivityCompat#requestPermissions for more details.
                    return;
                }
    startActivity(callIntent);
    

    Also, you should register the custom dialscreen as follows in the manifest:

    <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MyDialerApplication"
        android:label="@string/app_name" >
    
        <intent-filter android:priority="100" >
            <action android:name="android.intent.action.MAIN" />
             <action android:name="android.intent.action.DIAL" />
             <action android:name="android.intent.action.CALL_PRIVILEGED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />
    
        </intent-filter>
    </activity>
    

    0 讨论(0)
提交回复
热议问题