4

Our app needs to become the default dialer app (also known as: "default phone handler", "default calling app") so it'll be able to make calls under Android's new permissions policy.

We use the following intent to show a system dialog to ask the user to make our app the default:

Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getPackageName());
startActivityForResult(intent, RC_DEFAULT_PHONE);  

This works well on all our test devices, and apparently for most users, but doesn't show any dialog and immediately returns a RESULT_CANCELED result code for some devices.

By looking at the reports, it seems like the majority if not all reports are coming from Huawei devices (and from Huawei's brand - Honor).

Any idea how to display the default call app dialog on those devices?
Any other intent we can run to help the user manually set our app to be the default calling app?

marmor
  • 27,641
  • 11
  • 107
  • 150

3 Answers3

0

some googling returned that honor devices require you to change the default dialer app in settings, maybe launch intent to that settings page directly? as for the particular settings page argument, you will have to check on a honor device

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

then you can handle the result in your application(by checking if your dialer is default now) else tell user about failure

Karan Harsh Wardhan
  • 1,096
  • 9
  • 22
0

I had the same problem while building dialer app Starting from the release Q android os must but this code to ask default dialer in phone >= Q android

private static final int CHANGE_DEFAULT_DIALER_CODE =25 ;

private void offerReplacingDefaultDialer() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
        Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
        intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
                this.getPackageName());
        startActivity(intent);

    }
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
        RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
        Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER);
        startActivityForResult(intent, CHANGE_DEFAULT_DIALER_CODE);
    }
}
-1

Maybe adding following <intent-filter> solve the problem:

<intent-filter>
      <action android:name="android.intent.action.DIAL" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:scheme="tel"/>
</intent-filter>
Ali Shirvani
  • 533
  • 6
  • 15