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?
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);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.