• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.1.1.43
BBWebView Class Reference

Class for supporting access to private/corporate network resources through BlackBerry Dynamics SDK.

Inherits WebView.

Public Member Functions

 BBWebView (Context context)
 Construct a new WebView with a Context object. More...
 
 BBWebView (Context context, AttributeSet attrs)
 Construct a new WebView with layout parameters. More...
 
 BBWebView (Context context, AttributeSet attrs, int defStyleAttr)
 Construct a new WebView with layout parameters and a default style. More...
 
 BBWebView (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
 Construct a new WebView with layout parameters and a default style. More...
 
void destroy ()
 Destroys the internal state of this WebView. More...
 
void setWebViewClient (WebViewClient client)
 Sets the WebViewClient that will receive various notifications and requests. More...
 
WebViewClient getWebViewClient ()
 Returns the internal BB SDK WebViewClient for supporting WebClientObserver class. More...
 
void setWebChromeClient (WebChromeClient client)
 Sets the chrome handler. More...
 
WebChromeClient getWebChromeClient ()
 Returns User's WebChromeClient for this BBWebView. More...
 
boolean onDragEvent (DragEvent event)
 Handles drag events sent by the system. More...
 
InputConnection onCreateInputConnection (EditorInfo outAttrs)
 Creates a new InputConnection for an InputMethod to interact with the WebView. More...
 
void loadUrl (String url, Map< String, String > additionalHttpHeaders)
 Loads the given URL with additional HTTP headers. More...
 
void loadUrl (String url)
 Loads the given URL. More...
 
void loadData (@NonNull String data, @Nullable String mimeType, @Nullable String encoding)
 Loads the given data into this WebView using a 'data' scheme URL. More...
 
void loadDataWithBaseURL (@Nullable String baseUrl, @NonNull String data, @Nullable String mimeType, @Nullable String encoding, @Nullable String historyUrl)
 Loads the given data into this WebView, using baseUrl as the base URL for the content. More...
 
void goBack ()
 Steps back in the history of this WebView. More...
 
List< BBAuthSchemegetAuthenticationPreferences ()
 Get authentication preferences for this WebView instance. More...
 
void setAuthenticationPreferences (List< BBAuthScheme > authPreferences)
 Set authentication preferences for this WebView instance. More...
 

Static Public Member Functions

static void showDownloadDirectory (Context context)
 Open the BBWebView Downloads user interface. More...
 
static String getDownloadDirectoryPath ()
 Get the BBWebView Downloads directory path. More...
 
static Intent provideBBDownloadIntent (Context context, boolean allowMultipleFilesSelection)
 Get the BBWebView Downloads Intent. More...
 
static Uri[] getUrisFromIntent (Intent intent)
 Get the BB Uris with selected files from BB Intent data. More...
 

Constructor & Destructor Documentation

◆ BBWebView() [1/4]

BBWebView ( Context  context)

Construct a new WebView with a Context object.

Parameters
contextA Context object used to access application assets.

◆ BBWebView() [2/4]

BBWebView ( Context  context,
AttributeSet  attrs 
)

Construct a new WebView with layout parameters.

Parameters
contextA Context object used to access application assets.
attrsAn AttributeSet passed to our parent.

◆ BBWebView() [3/4]

BBWebView ( Context  context,
AttributeSet  attrs,
int  defStyleAttr 
)

Construct a new WebView with layout parameters and a default style.

Parameters
contextA Context object used to access application assets.
attrsAn AttributeSet passed to our parent.
defStyleAttrAn attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

◆ BBWebView() [4/4]

BBWebView ( Context  context,
AttributeSet  attrs,
int  defStyleAttr,
int  defStyleRes 
)

Construct a new WebView with layout parameters and a default style.

Parameters
contextA Context object used to access application assets.
attrsAn AttributeSet passed to our parent.
defStyleAttrAn attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.
defStyleResA resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

Member Function Documentation

◆ destroy()

void destroy ( )

Destroys the internal state of this WebView.

Refer to the equivalent method destroy() in the API Guide on the developer.android.com site.

◆ setWebViewClient()

void setWebViewClient ( WebViewClient  client)

Sets the WebViewClient that will receive various notifications and requests.

webView.setWebViewClient(new BBWebViewClient () {
@Override
public boolean shouldOverrideUrlLoading (WebView view, WebResourceRequest request) {
if (request.getUrl().toString().startsWith("https://example.com")) {
Log.i("BBWebViewClient", "shouldOverrideUrlLoading() forbidden loading url");
return true;
} else {
Log.i("BBWebViewClient", "shouldOverrideUrlLoading() continue loading url");
return false;
}
}
@Override
public void onPageFinished(WebView view, String url) {
Log.i("BBWebViewClient", "onPageFinished() url is loaded");
}
});

Refer to the equivalent method setWebViewClient in the API Guide on the developer.android.com site.

◆ getWebViewClient()

WebViewClient getWebViewClient ( )

Because WebClientObserver class is deprecated, it will be removed in the next release and this method will start returning User's WebViewClient.

Refer to the equivalent method getWebViewClient in the API Guide on the developer.android.com site.

◆ setWebChromeClient()

void setWebChromeClient ( WebChromeClient  client)

This is an implementation of WebChromeClient for use in handling JavaScript dialogs, favicons, titles, and the progress. This will replace the current handler.

Sets the chrome handler. This is an implementation of WebChromeClient for use in handling JavaScript dialogs, favicons, titles, and the progress. This will replace the current handler.

webView.setWebChromeClient(new BBWebChromeClient () {
@Override
public void onProgressChanged(WebView view, int newProgress) {
Log.i("BBWebChromeClient", "onProgressChanged() progress = " + newProgress);
}
});

Refer to the equivalent method setWebChromeClient in the API Guide on the developer.android.com site.

◆ getWebChromeClient()

WebChromeClient getWebChromeClient ( )

Refer to the equivalent method getWebChromeClient in the API Guide on the developer.android.com site.

◆ onDragEvent()

boolean onDragEvent ( DragEvent  event)

Handles drag events sent by the system.

Refer to the equivalent method onDragEvent in the API Guide on the developer.android.com site.

◆ onCreateInputConnection()

InputConnection onCreateInputConnection ( EditorInfo  outAttrs)

Creates a new InputConnection for an InputMethod to interact with the WebView.

Refer to the equivalent method onCreateInputConnection in the API Guide on the developer.android.com site.

◆ loadUrl() [1/2]

void loadUrl ( String  url,
Map< String, String >  additionalHttpHeaders 
)

Loads the given URL with additional HTTP headers, specified as a map from name to value.

Refer to the equivalent method loadUrl() in the API Guide on the developer.android.com site.

◆ loadUrl() [2/2]

void loadUrl ( String  url)

Loads the given URL.

Refer to the equivalent method loadUrl() in the API Guide on the developer.android.com site.

◆ loadData()

void loadData ( @NonNull String  data,
@Nullable String  mimeType,
@Nullable String  encoding 
)

Loads the given data into this WebView using a 'data' scheme URL.

Refer to the equivalent method loadData in the API Guide on the developer.android.com site.

◆ loadDataWithBaseURL()

void loadDataWithBaseURL ( @Nullable String  baseUrl,
@NonNull String  data,
@Nullable String  mimeType,
@Nullable String  encoding,
@Nullable String  historyUrl 
)

Loads the given data into this WebView, using baseUrl as the base URL for the content.

Refer to the equivalent method loadData() in the API Guide on the developer.android.com site.

◆ goBack()

void goBack ( )

Steps back in the history of this WebView.

Refer to the equivalent method goBack() in the API Guide on the developer.android.com site.

◆ getAuthenticationPreferences()

List<BBAuthScheme> getAuthenticationPreferences ( )

Get authentication preferences for this WebView instance.

Returns
An array which was previously set for this WebView or null.

◆ setAuthenticationPreferences()

void setAuthenticationPreferences ( List< BBAuthScheme authPreferences)

Set authentication preferences for this WebView instance.

Call this method to set authentication schemes in order of preference. The first element is the highest priority and the last element is the least priority.

BB WebView will use this values to select authentication scheme for HTTP authentication.

If provided list is empty or 'null', then BB WebView will use default authentication preferences. Provide 'null' value if you want to restore BB WebView default behavior.

// Set authentication preference list where NTLM scheme is the first priority here.
webView.setAuthenticationPreferences(Arrays.asList(AuthSchemes.NTLM, AuthScheme.KERBEROS));
// Implement authentication callback and provide credential based on authentication scheme information.
webView.setWebViewClient(new BBWebViewClient () {
@Override
public void onReceivedBBHttpAuthRequest(WebView view, BBHttpAuthHandler handler, String host, String realm) {
// Check authentication scheme and provide credentials
if (handler.getAuthScheme() == AuthScheme.NTLM)) {
// Provide the authorization credentials for NTLM
handler.proceed("domain\\user_name", "user_password");
} else if (handler.getAuthScheme() == AuthScheme.KERBEROS)) {
// Provide the authorization credentials for Kerberos
handler.proceed("user_name@domain", "user_password");
}
}
});
// Load a resource under NTLM authentication.
webView.loadUrl("https://resource.example.com/");
Parameters
authPreferencesAn authentication preference list

◆ showDownloadDirectory()

static void showDownloadDirectory ( Context  context)
static

Open BBWebView Downloads user interface.

Call this method to show the BBWebView Downloads user interface with a list of downloaded files in Download directory.

◆ getDownloadDirectoryPath()

static String getDownloadDirectoryPath ( )
static

Get the BBWebView Downloads directory path.

Call this method to get the path to the BBWebView Downloads directory in the secure file system. You can access downloaded files using the BlackBerry Dynamics Secure Storage APIs (com.good.gd.file).

◆ provideBBDownloadIntent()

static Intent provideBBDownloadIntent ( Context  context,
boolean  allowMultipleFilesSelection 
)
static

Get the BBWebView Downloads Intent.

Call this method to get the BB Intent to open the BBWebView activity for file choosing from the BBWebView Downloads directory.

// Get your activity context in your application
Context context = ...
// Allow or disallow multiple file selection
boolean allowMultipleFilesSelection = ...
// Get BB Intent
Intent bbIntent = BBWebView.provideBBDownloadIntent(context, allowMultipleFilesSelection);
// Start it from your activity when user need to select a file from the BBWebView Downloads directory.
int requestCode = 1; // Specify your activity request code
context.startActivityForResult(bbIntent, requestCode);
Parameters
contextA Context of the application for Intent creation.
allowMultipleFilesSelectionWhether allow or disallow an user to select multiple files from the BBWebView Downloads directory.
Returns
An Intent for starting BBWebView Downloads activity.

◆ getUrisFromIntent()

static Uri [] getUrisFromIntent ( Intent  intent)
static

Get the BB Uris with selected files from BB Intent data.

Call this method to get the BB Uris for file uploading from the BBWebView Downloads directory in your activity callback method. You should pass these BB Uris to Android WebView by calling appropriate callback.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Get BB Uris from the Intent
Uri[] fileUris = BBWebView.getUriFromIntent(intent);
// Check if it's not null
if (fileUris != null) {
// Get WebView callback interface
ValueCallback<Uri[]> filePathCallback = ...
// Pass BB Uris to Android WebView
filePathCallback.onReceiveValue(fileUris);
}
}
Parameters
intentAn Intent received from onActivityResult() callback.
Returns
An uri array which contains user selected files from the BBWebView Downloads directory.
com.blackberry.bbwebview.BBWebView.BBWebView
BBWebView(Context context)
Construct a new WebView with a Context object.
Definition: BBWebView.java:117