-1

This code is working until Android 10/Q. when this function is called it doesn't pop up anymore like it did in old version before Android 10.

public static void promptDefaultHandler(Context context) {
    Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
    intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, context.getPackageName());
   
    context.startActivity(intent);
}

There is an error in the logcat which is not clear to me what is wrong.

2020-09-05 14:53:35.227 1818-2685/? W/PermissionPolicyService: Action Removed: starting Intent { act=android.provider.Telephony.ACTION_CHANGE_DEFAULT cmp=com.google.android.permissioncontroller/com.android.packageinstaller.role.ui.RequestRoleActivity (has extras) } from free.text.sms (uid=10338)

Any tip how to fix this?

mboy
  • 744
  • 7
  • 17

1 Answers1

1

It works with roleManager

RoleManager roleManager = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        roleManager = getApplicationContext().getSystemService(RoleManager.class);

        if (roleManager.isRoleAvailable(RoleManager.ROLE_SMS)) {
            if (roleManager.isRoleHeld(RoleManager.ROLE_SMS)) {
            } else {
                Intent roleRequestIntent = roleManager.createRequestRoleIntent(
                        RoleManager.ROLE_SMS);
                startActivityForResult(roleRequestIntent, 2);
            }
        }
    }

source - https://stackoverflow.com/a/60372137/1114170

mboy
  • 744
  • 7
  • 17