question

robin avatar image
robin asked

Launching Html5 hyperlink URLs into Silk browser from hybrid app

The response to the forum post threadID=2857 indicates it is allowable to launch URL hyperlinks into the Silk browser for hybrid apps. [1] Using an Html anchor element works for ver 2 WebAppTester: i.e. a href=" http://www.w3.org/TR/html5/" target="_blank" and I was able to do so inside a hybrid app Kindle OS 7.4.6 prior to including the new Amazon WebView libs [2] webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView webView, String url) { return false; Now, those same links are locked inside my hybrid attempt, despite not having present this override method @Override shouldOverrideUrlLoading() Since 'return false' should block URLs loading into Silk, not having the method should not be able to provide the blocking, thus allowing the launch into the Silk browser. This does not occur. I attempted to 'return true' inside an override method, but are unable to compile within the Amazon WebView. I attempted many variants but unable to guess the syntax for the Amazon flavors for WebViewClient() Eclipse err: "The method setWebViewClient(AmazonWebViewClient) in the type AmazonWebView is not applicable for the arguments (new WebViewClient(){}) The only documentation content I was able to locate via amazon search on Html5 hybrid apps [3] I also note that there has been a Kindle OS upgrade to 7.4.9 from 7.4.6 What is the correct syntax and code method placement to allow launching URLs into a Silk browser instance? Robin [1] https://forums.developer.amazon.com/forums/thread.jspa?threadID=2857 [2] https://developer.amazon.com/sdk/fire/IntegratingAWV.html [3] https://developer.amazon.com/public/solutions/platforms/android-fireos/docs/understanding-hybrid-apps
web apps
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); if (!sFactoryInit) { factory = AmazonWebKitFactories.getDefaultFactory(); if (factory.isRenderProcess(this)) { return; } factory.initialize(this); factory.getCookieManager().setAcceptCookie(true); sFactoryInit = true; } else { factory = AmazonWebKitFactories.getDefaultFactory(); } AmazonWebView mWebView = (AmazonWebView) findViewById(R.id.webView); factory.initializeWebView(mWebView, 0xFFFFFF, false, null); mWebView.getSettings().setJavaScriptEnabled(true); String url="file:///android_asset/test/index.html"; mWebView.loadUrl(url); } This should launch the page in Silk or other browser installed in device. 7.4.9 is the latest OS for Kindle HD, please update your device os. You do not need to use shouldOverrideUrlLoading() since launching the hyperlink in browser is the default behavior for Android or Amazon web view. Let me know if you have any further query on this. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Another note is please download the latest version of awv, I have tested above code with the recent most version and it works ok.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robin avatar image
robin answered
Between downloading the recent updated .jar lib files, the example above, and working this quick tutorial: https://developer.chrome.com/multidevice/webview/gettingstarted I was able to retain, launched from app domain URL requests within the Web View and launch external requests in Silk. Thank you for the updates. Robin
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.