Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment OR Data link open in system browser for the supported android 13 new changes Added. #1001

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CharanTatu
Copy link

@CharanTatu CharanTatu commented May 3, 2023

The code supported Android API levels of more than 13 also the Google Pixel 7 pro for the capacitor user. also Cordova .

Platforms affected

Motivation and Context

Description

Testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

The code supported Android API levels of more than 13 also the Google Pixel 7 pro for the capacitor user. also Cordova .
@CharanTatu CharanTatu closed this May 3, 2023
@CharanTatu CharanTatu reopened this May 3, 2023
@CharanTatu
Copy link
Author

Hi, all this code is perfectly working for payment links Or data links open in system browser support for Android 13.

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 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();
            }

@@ -454,20 +454,46 @@ private HashMap<String, String> parseFeature(String optString) {
*/
public String openExternal(String url) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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();
            }

@CharanTatu CharanTatu changed the title New changes added for the system browser open Payment OR Data link open in system browser for the supported android 13 new changes Added. Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant