Android Question Make app to default dialer

S.M.R

Member
Hello
i need to make my app to default dialer

after search i found solution in below link :
https://stackoverflow.com/questions/54190881/android-how-to-make-a-default-dialer-app

and solution is :
Java:
   private void setDefaultDialer()


 {
    AlertDialog.Builder builder;
    builder = new AlertDialog.Builder(this);
    builder.setMessage("Do you want to make Cricket your default Dialer?(it will not cover or replace your dialer)")
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    defaultDialerPackage = "cricket";
                    Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
                    startActivityForResult(intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,getPackageName()),REQUEST_CODE_SET_DEFAULT_DIALER);
                }
            })
            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    Toast.makeText(getApplicationContext(),"Cancelled - No action was taken",
                            Toast.LENGTH_SHORT).show();
                }
            });

AlertDialog alert = builder.create();
alert.setTitle("Cricket need default dialer permission!!");
alert.show();


How i can use solution in B4A ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

S.M.R

Member
The only important line in the Java code is line 13.

Example of StartActivityForResult: https://www.b4x.com/android/forum/t...list-of-other-related-methods.129897/#content

The constant value is "android.telecom.action.CHANGE_DEFAULT_DIALER".

However, if you read the documentation you will see that it will not work on Android 10+ devices.


Thanks for your answer.

So how I can check if my app isn't default dialer show a dialog system for choose like bellow picture on android 10+



Screenshot_20211110-005143_Permission controller.jpg
 
Upvote 0
Top