The Acoustic Analytics Developer Hub

Welcome to the Acoustic Analytics developer hub. You'll find comprehensive guides and documentation to help you start working with Acoustic Analytics as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Accessing native Android methods with JavaScript through Tealeaf customized WebView

Skill Level: Any

Overview

When you create hybrid applications, you can access native Android methods with JavaScript using the customized WebView.

Prerequisites

Before you begin, you must:

  • Install and implement the most recent Acoustic Experience Analytics (Tealeaf)Android SDK.
  • Include the most recent UI Capture j2 JavaScript source file.

Step-by-step

1. Add WebView to your application.

Specify a length, height, weight, and ID that suits your application:

<WebView
 android:id="@+id/my_webview"
 android:layout_width="match_parent"
 android:layout_height="0dp"
 android:layout_weight="1" />

2. In your activity, locate the WebView and load your HTML file:

public class MainActivity extends ActionBarActivity {
 private UICWebView mUICWebView;
 private String logicalPageName = "BridgeAppActivity";
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 // Initialize tealeaf with a reference to application
 Tealeaf tealeaf = new Tealeaf(this.getApplication());
 
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 // Load HTML file from local resource in the UICWebview
 mUICWebView = (UICWebView) findViewById(R.id.uic_webview);
 // Modify the Url for your hybrid app 
 mUICWebView.loadUrl("file:///android_asset/www/test.html");
 WebSettings webSettings = mUICWebView.getSettings();
 webSettings.setJavaScriptEnabled(true);
 }

3. Copy the application's files

Copy the application's HTML and JavaScript files to the /assets/www folder in your Android project.

Updated a day ago


Accessing native Android methods with JavaScript through Tealeaf customized WebView


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.