0

I'm working on launching a pop-up link (an Amazon shopping cart) out of my webView, and I have it working so that the cart loads in the web browser, which was my original intent. But, I'm interested in using Chrome Custom Tabs to make the transition seem a little smoother. All of the examples of Chrome Custom Tabs that I've seen seem to follow the pattern below:

  CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, uri,
    new CustomTabActivityHelper.CustomTabFallback() {
        @Override
        public void openUri(Activity activity, Uri uri) {
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    }); 

Now we've reached the crux of my issue-- I'm not sure how to access the uri from the onCreateWindow method, which is where I would be launching the Chrome Custom Tabs. Currently, my code is as follows:

 @Override
 public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture,
                                          Message resultMsg) {
                WebView wv = new WebView(getApplicationContext());
                final WebSettings settings = wv.getSettings();
                settings.setJavaScriptEnabled(true);
                wv.setWebChromeClient(this);
                wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
                WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
                transport.setWebView(wv);
                resultMsg.sendToTarget();

                return true;
            }

I've looked at a few other posts, namely Handle url from onCreateWindow web view, but I haven't found much success. So if anyone has any suggestions about how to either grab the url in the onCreateWindow method or a way to otherwise launch Chrome Custom Tabs in that circumstance, it'd be much appreciated

2
  • Were you able to solve this? Sep 26, 2016 at 19:14
  • @JavierMarín No -- I just kept things as they were, i.e. launched the external webpage in chrome
    – Ethan
    Sep 28, 2016 at 15:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.