Merge pull request #9758 from Stypox/fix-api33-links-again
Fix opening links on Android 12+
This commit is contained in:
commit
4903786b14
|
@ -89,14 +89,12 @@ public final class ShareUtils {
|
||||||
if (defaultPackageName.equals("android")) {
|
if (defaultPackageName.equals("android")) {
|
||||||
// No browser set as default (doesn't work on some devices)
|
// No browser set as default (doesn't work on some devices)
|
||||||
openAppChooser(context, intent, true);
|
openAppChooser(context, intent, true);
|
||||||
} else {
|
|
||||||
if (defaultPackageName.isEmpty()) {
|
|
||||||
// No app installed to open a web url
|
|
||||||
Toast.makeText(context, R.string.no_app_to_open_intent, Toast.LENGTH_LONG).show();
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
// will be empty on Android 12+
|
||||||
|
if (!defaultPackageName.isEmpty()) {
|
||||||
intent.setPackage(defaultPackageName);
|
intent.setPackage(defaultPackageName);
|
||||||
|
}
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} catch (final ActivityNotFoundException e) {
|
} catch (final ActivityNotFoundException e) {
|
||||||
// Not a browser but an app chooser because of OEMs changes
|
// Not a browser but an app chooser because of OEMs changes
|
||||||
|
@ -104,7 +102,6 @@ public final class ShareUtils {
|
||||||
openAppChooser(context, intent, true);
|
openAppChooser(context, intent, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue