android default sms app request
public void makeMyAppDefaultRequest(String packageName){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
RoleManager roleManager =getSystemService(RoleManager.class);
if (roleManager.isRoleAvailable(RoleManager.ROLE_SMS)) {
if (roleManager.isRoleHeld(RoleManager.ROLE_SMS)) {
requestPermission()
} else {
Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS);
startActivityForResult(intent, 101);
}
} else {
}
} else {
if (Telephony.Sms.getDefaultSmsPackage(this).equals(packageName)) {
} else {
Intent intent =new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName);
startActivityForResult(intent, 101);
}
}
}