Overview

Skill Level: Any

Prerequisites

Before you begin, you must:

  • Install and implement the most recent TealeafAndroid 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 HTML and JavaScript files to the /assets/www folder in your Android project.

Join The Discussion

Your email address will not be published. Required fields are marked *