You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "CharanTatu (via GitHub)" <gi...@apache.org> on 2023/06/29 17:17:52 UTC
[GitHub] [cordova-plugin-inappbrowser] CharanTatu commented on a diff in pull request #1001: New changes added for the system browser open
CharanTatu commented on code in PR #1001:
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/1001#discussion_r1246922741
##########
src/android/InAppBrowser.java:
##########
@@ -454,20 +454,46 @@ private HashMap<String, String> parseFeature(String optString) {
*/
public String openExternal(String url) {
Review Comment:
try {
Uri uri = Uri.parse(url);
String scheme = uri.getScheme();
Intent intent = null;
intent = "data".equals(scheme)
? Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_BROWSER)
: new Intent(Intent.ACTION_VIEW);
if ("file".equals(scheme)) {
intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
} else {
intent.setData(uri);
}
// intent.setPackage("com.android.chrome"); // Specify the package name of Chrome
PackageManager packageManager = cordova.getActivity().getPackageManager();
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
if (resolveInfoList.size() > 0) {
cordova.getActivity().startActivity(Intent.createChooser(intent, "com.android.chrome"));
} else {
// Chrome is not installed,
intent.setPackage(null);
cordova.getActivity().startActivity(Intent.createChooser(intent, "com.android.chrome"));
}
return "";
} catch (Exception e) {
LOG.d(LOG_TAG, "InAppBrowser: Error loading url " + url + ": " + e.toString());
return e.toString();
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org