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-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to