com.amazon.android.webkit.AmazonWebViewClient Java Examples
The following examples show how to use
com.amazon.android.webkit.AmazonWebViewClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InAppBrowser.java From ultimate-cordova-webview-app with MIT License | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #2
Source File: InAppBrowser.java From AvI with MIT License | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #3
Source File: InAppBrowser.java From reacteu-app with MIT License | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #4
Source File: InAppBrowser.java From showCaseCordova with Apache License 2.0 | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #5
Source File: InAppBrowser.java From reader with MIT License | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #6
Source File: InAppBrowser.java From reader with MIT License | 5 votes |
/** * Closes the dialog */ public void closeDialog() { final AmazonWebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.setWebViewClient(new AmazonWebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(AmazonWebView view, String url) { if (dialog != null) { dialog.dismiss(); } } }); // NB: From SDK 19: "If you call methods on WebView from any thread // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }
Example #7
Source File: CordovaActivity.java From cordova-amazon-fireos with Apache License 2.0 | 5 votes |
/** * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable). * The errorCode parameter corresponds to one of the ERROR_* constants. * * @param errorCode The error code corresponding to an ERROR_* value. * @param description A String describing the error. * @param failingUrl The url that failed to load. */ public void onReceivedError(final int errorCode, final String description, final String failingUrl) { final CordovaActivity me = this; // If errorUrl specified, then load it final String errorUrl = preferences.getString("errorUrl", null); if ((errorUrl != null) && (errorUrl.startsWith("file://") || internalWhitelist.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) { // Load URL on UI thread me.runOnUiThread(new Runnable() { public void run() { me.appView.showWebPage(errorUrl, false, true, null); } }); } // If not, then display error dialog else { final boolean exit = !(errorCode == AmazonWebViewClient.ERROR_HOST_LOOKUP); me.runOnUiThread(new Runnable() { public void run() { if (exit) { me.appView.setVisibility(View.GONE); me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit); } } }); } }
Example #8
Source File: CordovaWebViewClient.java From cordova-amazon-fireos with Apache License 2.0 | 5 votes |
/** * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable). * The errorCode parameter corresponds to one of the ERROR_* constants. * * @param view The AmazonWebView that is initiating the callback. * @param errorCode The error code corresponding to an ERROR_* value. * @param description A String describing the error. * @param failingUrl The url that failed to load. */ @Override public void onReceivedError(AmazonWebView view, int errorCode, String description, String failingUrl) { // Ignore error due to stopLoading(). if (!isCurrentlyLoading) { return; } LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl); // Clear timeout flag this.appView.loadUrlTimeout++; // If this is a "Protocol Not Supported" error, then revert to the previous // page. If there was no previous page, then punt. The application's config // is likely incorrect (start page set to sms: or something like that) if (errorCode == AmazonWebViewClient.ERROR_UNSUPPORTED_SCHEME) { if (view.canGoBack()) { view.goBack(); return; } else { super.onReceivedError(view, errorCode, description, failingUrl); } } // Handle other errors by passing them to the webview in JS JSONObject data = new JSONObject(); try { data.put("errorCode", errorCode); data.put("description", description); data.put("url", failingUrl); } catch (JSONException e) { e.printStackTrace(); } this.appView.postMessage("onReceivedError", data); }