public class

UAWebViewClient

extends WebViewClient
java.lang.Object
   ↳ android.webkit.WebViewClient
     ↳ com.urbanairship.widget.UAWebViewClient

Class Overview

A web view client that intercepts Urban Airship URLs and enables triggering actions from javascript.

The UAWebViewClient will intercept links with the 'uairship' scheme and with the commands (supplied as the host) 'run-actions' or 'run-basic-actions'.

The run-actions command runs a set of actions listed in the URL's query options, by providing key=value pairs, where each pair's key is the name of an action and the value is a JSON encoded string representing the value of the action's ActionArguments. The JSON encoded string is decoded and converted to a List if the argument is a JSONArray or a Map if the argument is a JSONObject.

Example: uairship://run-actions?&add_tags_action=%5B%22one%22%2C%22two%22%5D will run the "add_tags_action" with value "["one", "two"]".

The run-basic-actions command is similar to run-actions, but the argument value is treated as a string literal.

Example: uairship://run-basic-actions?add_tags_action=one&remove_tags_action=two will run the "add_tags_action" with the value "one", and perform the "remove_tags_action" action with value "two".

When extending this class, any overridden methods should call through to the super class' implementations.

Summary

Constants
String CLOSE_COMMAND Close command to handle close method in the Javascript Interface.
String RUN_ACTIONS_COMMAND Run actions command.
String RUN_BASIC_ACTIONS_COMMAND Run basic actions command.
String UA_ACTION_SCHEME Urban Airship's scheme.
[Expand]
Inherited Constants
From class android.webkit.WebViewClient
Public Constructors
UAWebViewClient()
Default constructor.
Public Methods
void onClose(WebView webView)
Called when UAirship.close() is triggered from the Urban Airship Javascript interface.
void onLoadResource(WebView webView, String url)
void onPageFinished(WebView view, String url)
void onPageStarted(WebView view, String url, Bitmap favicon)
void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm)
void setActionCompletionCallback(ActionCompletionCallback actionCompletionCallback)
Sets the action completion callback to be invoked whenever an Action is finished running from the web view.
WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest request)
Intercepts the favicon request and returns null favicon
WebResourceResponse shouldInterceptRequest(WebView webView, String url)
Intercepts the favicon request and returns a null favicon
boolean shouldOverrideUrlLoading(WebView webView, String url)
[Expand]
Inherited Methods
From class android.webkit.WebViewClient
From class java.lang.Object

Constants

public static final String CLOSE_COMMAND

Close command to handle close method in the Javascript Interface.

Constant Value: "close"

public static final String RUN_ACTIONS_COMMAND

Run actions command.

Constant Value: "run-actions"

public static final String RUN_BASIC_ACTIONS_COMMAND

Run basic actions command.

Constant Value: "run-basic-actions"

public static final String UA_ACTION_SCHEME

Urban Airship's scheme. The web view client will override any URLs that have this scheme by default.

Constant Value: "uairship"

Public Constructors

public UAWebViewClient ()

Default constructor.

Public Methods

public void onClose (WebView webView)

Called when UAirship.close() is triggered from the Urban Airship Javascript interface.

The default behavior simulates a back key press.

Parameters
webView The web view.

public void onLoadResource (WebView webView, String url)

public void onPageFinished (WebView view, String url)

public void onPageStarted (WebView view, String url, Bitmap favicon)

public void onReceivedHttpAuthRequest (WebView view, HttpAuthHandler handler, String host, String realm)

public void setActionCompletionCallback (ActionCompletionCallback actionCompletionCallback)

Sets the action completion callback to be invoked whenever an Action is finished running from the web view.

Parameters
actionCompletionCallback The completion callback.

public WebResourceResponse shouldInterceptRequest (WebView webView, WebResourceRequest request)

Intercepts the favicon request and returns null favicon

Parameters
webView The web view.
request The WebResourceRequest being loaded.
Returns
  • The tiny favicon image embedded in a WebResourceResponse or null if the url does not contain a favicon.

public WebResourceResponse shouldInterceptRequest (WebView webView, String url)

Intercepts the favicon request and returns a null favicon

Parameters
webView The web view.
url The url being loaded.
Returns
  • The null favicon image embedded in a WebResourceResponse or null if the url does not contain a favicon.

public boolean shouldOverrideUrlLoading (WebView webView, String url)