Android SDK Integration Guide

Install SDK

1. Copy the jar file from the downloaded package into your project's libs folder and import it using gradle

implementation files(`libs/OpoInstall_vX.X.X.jar`)

Alternatively, import all jar files in the libs directory

implementation fileTree(dir: 'libs', include: ['*.jar'])

2. (Optional) If your app is listed on the Google Play Store, you can add the following dependency to improve the accuracy of parameter restoration when downloading from the Google Play Store

implementation "com.android.installreferrer:installreferrer:2.2"

3. (Optional) If you encounter relevant warnings during ProGuard obfuscation, you can add the following code to your 'proguard-rules.pro' file

-keep class com.opoinstall.** { *; }

Initialize SDK

App Configuration

Modify your AndroidManifest.xml file for subsequent use

1. Add the following permissions to the manifest tag

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

2. Add your AppKey to the application tag

<meta-data
    android:name="com.opoinstall.APP_KEY"
    android:value="OPOINSTALL_APPKEY"/>

Initialization

Call the initialize method in your custom Application to initialize the SDK

import android.app.Application;
import import com.opoinstall.api.OpoInstall;
public class CustomApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    OpoInstall.initialize(this);
    }
}

Start SDK

In your startup Activity, call the start method to launch the SDK. This will trigger data collection and interaction with the server

OpoInstall.getInstance().start(this);

Feature Integration

Quick Installation

If you only need the quick installation feature and do not require other features (such as channel statistics, parameter-based installation restoration, or Deeplink), completing the initialization is sufficient

Deeplink

App Configuration

To support launching your app from other applications, modify the AndroidManifest.xml file and add the following configuration to the Activity responsible for handling web launches

<activity
    android:name=".MainActivity"
    android:exported="true"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="OPOINSTALL_SCHEME"/>
    </intent-filter>
</activity>

Obtain Launch Data

In the onCreate(Bundle) and onNewIntent(Intent) methods of the launched Activity, call handleDeepLink to process the intent that triggered the launch

public class OpenedActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        getWakeUpData(getIntent());
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        getWakeUpData(intent);
    }

    private void getWakeUpData(Intent intent) {
        OpoInstall.getInstance().handleDeepLink(intent, new ResultCallBack<OpoData>() {
            @Override
            public void onResult(OpoData opoData) {
                Log.d(TAG, "handleDeepLink onResult : " + opoData);
            }

            @Override
            public void onError(OpoError opoError) {
                Log.d(TAG, "handleDeepLink onError : " + opoError);
            }
        });
    }
}

Parametric Installation Advanced Feature

Use 'getInstallParam' to retrieve dynamic parameters from the web. Get specific installation parameters in the callback

OpoInstall.getInstance().getInstallParam(new ResultCallBack<OpoData>() {
    @Override
    public void onResult(OpoData opoData) {
        Log.d(TAG, "getInstallParam onResult : " + opoData);
    }

    @Override
    public void onError(OpoError opoError) {
        Log.e(TAG, "getInstallParam onError : " + opoError);
    }
});

Channel Statistics Advanced Feature

Standard Events

You can call the register method to report registration events

OpoInstall.getInstance().register();

The system automatically reports app active events. Call setAutoCollect to disable the SDK's internal event collection until it is re-enabled

OpoInstall.getInstance().setAutoCollect(false);

Custom Events

You can use the saveEvent method to report custom events. The first parameter represents the event ID, and the second parameter represents the event value.
When calling this API, ensure that the event ID in the code matches the event ID created in the dashboard

OpoInstall.getInstance().saveEvent("effect_test", 1);

Additionally, you can pass up to 5 custom parameters related to the event to more accurately evaluate channel effects and user behavior.
Before calling this API, please enable "Record Details" and add custom parameters in the "Effect Point Management" section of the dashboard

Map<String, String> extra = new HashMap<>();
extra.put("xxx", "123");
extra.put("zzz", "xyz");
OpoInstall.getInstance().saveEvent("effect_test", 1, extra);

Fission Sharing Advanced Feature

The main purpose of sharing reports is to track which platform a specific user shared to during a sharing campaign, and then bind the shared user's information through JS to further track the activation and retention of the shared users. The SDK has pre-defined most mainstream sharing platforms in the enum class 'OpSharePlatform', which can be passed directly.
To track sharing activation and retention, trigger this API before the user clicks the share button

OpoInstall.getInstance().reportShare("code123456", "X", new ResultCallBack<Void>() {
    @Override
    public void onResult(Void unused) {
        Log.d(TAG, "reportShare success");
    }
    @Override
    public void onError(OpoError opoError) {
        Log.w(TAG, "reportShare fail : " + opoError);
    }
});