OZ e-Form Developer
  • OZ e-Form Concepts
  • 🌈e-Form DEVELOPER
    • Day 1: Welcome On Board
      • About Course
      • Preparations
      • OZ e-Form Overview
    • Day 2: e-Form Design
      • Designer Environments
      • e-Form Layout Structure
      • e-Form Components
      • e-Form From Documents
      • Preview / Export / Save
      • Hands-on Practice
    • Day 3: Dynamic e-Form
      • e-Form Scripting Guide
      • Hands-on Practice
      • Advanced Features
    • Day 4: e-Form Application
      • Server Deployment
      • Viewer In HTML
      • Viewer APIs
      • Prefilling e-Form
      • Submitting e-Form
      • Sending MemoryStream
    • Get Your Certificate
    • Design Guide
      • Dialogue Flow
        • Overview
        • Creating Dialogue Flow
        • Uploading e-Form to Server
        • Running Dialogue Flow
        • Group and Statement
        • Custom Styling
      • Multilingual e-Form
      • Miscellaneous
      • Videosign
        • Videosign User Guide
      • OZ Verifier
        • OZ Verifier Introduction
        • Implementation and Use
        • Requirements
      • HTML5 Editor
        • HTML5 Editor Introduction
        • HTML Editor
        • Requirements and Sample
    • Day 5. Server & Reporting
  • 🌈Server Developer
    • OZ Server Console
    • OZ Scheduler
      • Features
      • Installing OZ Scheduler
      • Scheduler Task
    • Binding & Exporting
      • Overview
      • Export API Example
        • Extract Input Data
        • Export with OZ Server
        • Export with Scheduler
        • Export with Scheduler Task
    • Repository Server
    • Sync Server
      • Overview
      • Installing Sync-Server
        • SSL configration
      • Sample Application
      • Implementation
    • QR Link Mobile Sign
  • 🌈Report Developer
    • Overview
      • About Course
      • Preparation
      • Report Designer Overview
    • Query Design
      • Database Connection
      • Designer Environment
      • Dataset Design
    • Report Design
      • Designer Environment
      • Components
      • Table
      • Master-Detail
      • ODI Parameter
      • CrossTab
      • Chart
  • 🌈MOBILE DEVELOPER
    • Android Native
    • iOS Native
    • TOTO Framework
      • TOTO Overview
      • Sample App Overview
      • Server Application
      • Android Project
  • ⬇️Product Downloads
  • 📚 Product Documentation
  • 📕Technical Guide
  • ⚛️ ReactJS Integration
Powered by GitBook
On this page
  • Learn how to
  • Preparations
  • Required skills/experiences
  • Android Studio
  • OZ products
  • Sample project
  • Add Android viewer library to project
  • Configurations
  • Add Submit button
  • Activity to open e-Form
  • Run your App

Was this helpful?

  1. MOBILE DEVELOPER

Android Native

PreviousChartNextiOS Native

Last updated 3 years ago

Was this helpful?

Learn how to

  1. Add Android Viewer library to your project

  2. Connect to the server, open Android viewer, and load an e-Form in your activity.

  3. Trigger the e-Form submit button from an action button

Preparations

Required skills/experiences

  • Android native App development experience with Android Studio or Eclipse.

Android Studio

  • Here we use Android Studio ver. 4.0.1

OZ products

  • e-Form Server installed on the WAS server

  • Android Viewer library

    Download ozrv80_android_version.number.tar.gz from 👉

Sample project

Create a new project with Empty Activity.

Add Android viewer library to project

Add Android viewer library and license file to your project as illustrated below. Your instructor will provide the license file.

For API levels before 28 that contain no androidx implementation, you have to add android-support-v4.jarto the libs and dependencies.

Configurations

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.forcs.android">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/Theme.Android">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-feature    android:name="android.hardware.camera" />
    <uses-feature    android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.NFC" />

</manifest>
build.gradle(:app)
plugins {
    id 'com.android.application'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.forcs.android"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation files('libs/ozrv_android.jar')
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}MainActivity.java

Add Submit button

Add menu_main.xml in res/menu folder.

menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.forcs.android.MainActivity">
    <item android:id="@+id/action_btn1"
        android:title="Submit"
        app:showAsAction="always" />
</menu>

Activity to open e-Form

MainActivity.java
package com.forcs.android;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;

// import OZ Viewer API
import oz.api.OZReportAPI;
import oz.api.OZReportCommandListener;
import oz.api.OZReportViewer;

public class MainActivity extends AppCompatActivity {

    // Load OZ Viewer library
    static {
        try {
            System.loadLibrary("skia_android");
            System.loadLibrary("ozrv");
        } catch (Exception e) {
            Log.e("OZRV", "Cannot load OZ Viewer library");
            e.printStackTrace();
        }
    }

    private FrameLayout mLayout; // declare content view for OZ Viewer
    private OZReportViewer mViewer; // declare OZ Viewer

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mLayout = new FrameLayout(this);
        setContentView(mLayout);
        openViewer();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle presses on the action bar items
        switch (item.getItemId()) {
            case R.id.action_btn1:
                submit();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void openViewer() {
        closeViewer();
        String params = "connection.servlet=http://oz.ozeform.io/oz/server";
        params += "\n" + "connection.reportname=demo/customer.ozr";
        mViewer = OZReportAPI.createViewer(mLayout, new OZReportCommandListener() {}, params);
    }

    private void closeViewer() {
        if(mViewer != null) {
            mViewer.dispose();
            mViewer = null;
        }
    }

    private  void submit() {
        String result = mViewer.GetInformation("INPUT_CHECK_VALIDITY");
        if (result.equals("valid")) {
            String data = mViewer.GetInformation("INPUT_JSON_ALL");
            dialogBox(data);
        }
    }

    private void dialogBox(String data) {
        AlertDialog.Builder dialog=new AlertDialog.Builder(this);
        dialog.setMessage(data);
        dialog.setTitle("Input Data");
        dialog.setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
        AlertDialog alertDialog=dialog.create();
        alertDialog.show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        closeViewer();
    }

}

Run your App

🌈
Product Downloads