Android SDK Integration Guide #
Install SDK #
1、Import the SDK in the ‘build.gradle’ file of your app
implementation("com.openinstallglobal.sdk:android-sdk:1.0.0")
2、(Optional) If your application is listed on the Google Play Store, you can add the following dependencies to improve the accuracy of parameter restoration during downloads from the Google Play Store
implementation "com.android.installreferrer:installreferrer:2.2"
3、(Optional) If you encounter warnings related to during ProGuard obfuscation, you can add the following code to your ‘proguard-rules.pro’ file
-keep class io.openinstall.** { *; }
Initialize SDK #
Application Configuration
Modify your AndroidManifest.xml file for future use
1、Add the following permissions in the manifest tag
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
2、Add your ‘s appkey in the application tag
<meta-data
android:name="com.openinstall.APP_KEY"
android:value="OPENINSTALL_APPKEY"/>
Initialization
Call the initialize method in your custom application to initialize the SDK
import android.app.Application;
import io.openinstall.api.OpenInstall;
public class CustomApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
OpenInstall.initialize(this);
}
}
Launch SDK
In your startup Activity, invoke the start method to initiate the SDK. This triggers data collection and interaction with the server
OpenInstall.getInstance().start(this);
Feature Integration #
Quick Installation #
If you only need the quick installation feature and no other features (e.g. channel statistics, application parameter installation, Deeplink), then completing the initialization is all that’s necessary
Deeplink #
Application Configuration
To enable launching your app from other apps, modify the AndroidManifest.xml file by adding 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="OPENINSTALL_SCHEME"/>
</intent-filter>
</activity>
Retrieve 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) {
OpenInstall.getInstance().handleDeepLink(intent, new ResultCallBack<OpData>() {
@Override
public void onResult(OpData opData) {
Log.d(TAG, "handleDeepLink onResult : " + opData);
}
@Override
public void onError(OpError opError) {
Log.d(TAG, "handleDeepLink onError : " + opError);
}
});
}
}
App Parameter Installation Advanced Features #
Use ‘getInstallParam’ for dynamic parameters from web page. Retrieve the installation parameters in the callback
OpenInstall.getInstance().getInstallParam(new ResultCallBack<OpData>() {
@Override
public void onResult(OpData opData) {
Log.d(TAG, "getInstallParam onResult : " + opData);
}
@Override
public void onError(OpError opError) {
Log.e(TAG, "getInstallParam onError : " + opError);
}
});
Channel Statistics Advanced Features #
Standard Events
You can call register method to report registrations
OpenInstall.getInstance().register();
Automatically reports active application events. Use setAutoCollect to disable internal event collection by the SDK until re-enabled
OpenInstall.getInstance().setAutoCollect(false);
Custom Events
Custom events can be reported using the saveEvent method. The first parameter represents the event ID, while the second parameter represents the event value
When calling the API, ensure the event ID in your code matches the event ID created in the console
OpenInstall.getInstance().saveEvent("effect_test", 1);
Additionally supports passing up to 5 custom parameters related to the event, providing a better evaluation of channel effectiveness and user behavior
Before calling the API, enable ‘Record Details’ and add custom parameters in the ‘Effect Point Management’ section of the console
Map<String, String> extra = new HashMap<>();
extra.put("xxx", "123");
extra.put("zzz", "xyz");
OpenInstall.getInstance().saveEvent("effect_test", 1, extra);
Viral SharingAdvanced Features #
The main purpose of share reporting is to track which platform a specific user shared to during a particular sharing session, then binding the shared user information through JS to further track the activation and return flow of shared users. The SDK has predefined most major sharing platforms in enum class ‘OpSharePlatform,’ allowing direct input
To track sharing activation and return flow, trigger this API before the user clicks the share button
OpenInstall.getInstance().reportShare("code123456", "X", new ResultCallBack<Void>() {
@Override
public void onResult(Void unused) {
Log.d(TAG, "reportShare success");
}
@Override
public void onError(OpError opError) {
Log.w(TAG, "reportShare fail : " + opError);
}
});