Skip to main content
BETA
HomeIntegration BuilderAPI ReferenceGuides
View Mirror World on Github
Join the Discord server

Language:

Android Integration Guide

This guide will walk you through the setup process for the Mirror World Smart SDK on Android.

1. Create a Developer Account

Create a developer account on the Developer dashboard. Create project and create an API Key. If you already have an API Key, you may skip this step and proceed to the next one.

Import the Mirror World SDK

Notice: The minimum version that SDK requires is Android 4.4.

  1. Download and uncompress Mirror World Android SDK.
  2. Put the mirrorsdk.aar under the libs folder. You may create a libs folder if it doesn't exist under your Project root > app directory.

android-install

  1. Install SDK dependency. In your build.gradle file, please add the Mirror World SDK as a dependency.
build.gradle
Copy

_3
dependencies {
_3
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
_3
}

2. Configuring CustomTab

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

Add permission for internet

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

build.gradle
AndroidManifest.xml
Copy

_52
<?xml version="1.0" encoding="utf-8"?>
_52
<manifest
_52
xmlns:android="http://schemas.android.com/apk/res/android"
_52
xmlns:tools="http://schemas.android.com/tools"
_52
package="com.mirror.mirrorworld_sdk_android"
_52
>
_52
_52
<uses-permission android:name="android.permission.INTERNET" />
_52
<queries>
_52
<intent>
_52
<action android:name="android.intent.action.VIEW" />
_52
<category android:name="android.intent.category.BROWSABLE" />
_52
<data android:scheme="https"/>
_52
</intent>
_52
</queries>
_52
_52
<application
_52
android:allowBackup="true"
_52
android:dataExtractionRules="@xml/data_extraction_rules"
_52
android:fullBackupContent="@xml/backup_rules"
_52
android:icon="@mipmap/ic_launcher"
_52
android:label="@string/app_name"
_52
android:networkSecurityConfig="@xml/network_security_config"
_52
android:roundIcon="@mipmap/ic_launcher_round"
_52
android:supportsRtl="true"
_52
android:theme="@style/Theme.Mirrorworldsdkandroid"
_52
tools:targetApi="31"
_52
>
_52
<activity
_52
android:name=".MainActivity"
_52
android:launchMode="singleTask"
_52
android:exported="true"
_52
>
_52
<intent-filter>
_52
<action android:name="android.intent.action.MAIN" />
_52
<category android:name="android.intent.category.LAUNCHER" />
_52
</intent-filter>
_52
</activity>
_52
_52
<activity
_52
android:name="com.mirror.sdk.activities.RedirectActivity"
_52
android:exported="true"
_52
>
_52
<intent-filter>
_52
<action android:name="android.intent.action.VIEW"/>
_52
<category android:name="android.intent.category.DEFAULT"/>
_52
<category android:name="android.intent.category.BROWSABLE"/>
_52
<data android:scheme="mwsdk"/>
_52
</intent-filter>
_52
</activity>
_52
</application>
_52
</manifest>

Update dependencies

Then add this to your gradle file:

build.gradle
Copy

_1
implementation 'androidx.browser:browser:1.4.0'

Register this activity

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

build.gradle
AndroidManifest.xml
Copy

_53
<?xml version="1.0" encoding="utf-8"?>
_53
<manifest
_53
xmlns:android="http://schemas.android.com/apk/res/android"
_53
xmlns:tools="http://schemas.android.com/tools"
_53
package="com.mirror.mirrorworld_sdk_android"
_53
>
_53
_53
<uses-permission android:name="android.permission.INTERNET" />
_53
<queries>
_53
<intent>
_53
<action android:name="android.intent.action.VIEW" />
_53
<category android:name="android.intent.category.BROWSABLE" />
_53
<data android:scheme="https"/>
_53
</intent>
_53
</queries>
_53
_53
<application
_53
android:allowBackup="true"
_53
android:dataExtractionRules="@xml/data_extraction_rules"
_53
android:fullBackupContent="@xml/backup_rules"
_53
android:icon="@mipmap/ic_launcher"
_53
android:label="@string/app_name"
_53
android:networkSecurityConfig="@xml/network_security_config"
_53
android:roundIcon="@mipmap/ic_launcher_round"
_53
android:supportsRtl="true"
_53
android:theme="@style/Theme.Mirrorworldsdkandroid"
_53
tools:targetApi="31"
_53
>
_53
<activity
_53
android:name=".MainActivity"
_53
android:launchMode="singleTask"
_53
android:exported="true"
_53
>
_53
<intent-filter>
_53
<action android:name="android.intent.action.MAIN" />
_53
<category android:name="android.intent.category.LAUNCHER" />
_53
</intent-filter>
_53
</activity>
_53
_53
<activity
_53
android:name="com.mirror.sdk.activities.RedirectActivity"
_53
android:exported="true"
_53
>
_53
<intent-filter>
_53
<action android:name="android.intent.action.VIEW"/>
_53
<category android:name="android.intent.category.DEFAULT"/>
_53
<category android:name="android.intent.category.BROWSABLE"/>
_53
<data android:scheme="mwsdk"/>
_53
</intent-filter>
_53
</activity>
_53
</application>
_53
_53
</manifest>

Complete Android Manifest

The final file will look something like this:

build.gradle
AndroidManifest.xml
Copy

_53
<?xml version="1.0" encoding="utf-8"?>
_53
<manifest
_53
xmlns:android="http://schemas.android.com/apk/res/android"
_53
xmlns:tools="http://schemas.android.com/tools"
_53
package="com.mirror.mirrorworld_sdk_android"
_53
>
_53
_53
<uses-permission android:name="android.permission.INTERNET" />
_53
<queries>
_53
<intent>
_53
<action android:name="android.intent.action.VIEW" />
_53
<category android:name="android.intent.category.BROWSABLE" />
_53
<data android:scheme="https"/>
_53
</intent>
_53
</queries>
_53
_53
<application
_53
android:allowBackup="true"
_53
android:dataExtractionRules="@xml/data_extraction_rules"
_53
android:fullBackupContent="@xml/backup_rules"
_53
android:icon="@mipmap/ic_launcher"
_53
android:label="@string/app_name"
_53
android:networkSecurityConfig="@xml/network_security_config"
_53
android:roundIcon="@mipmap/ic_launcher_round"
_53
android:supportsRtl="true"
_53
android:theme="@style/Theme.Mirrorworldsdkandroid"
_53
tools:targetApi="31"
_53
>
_53
<activity
_53
android:name=".MainActivity"
_53
android:launchMode="singleTask"
_53
android:exported="true"
_53
>
_53
<intent-filter>
_53
<action android:name="android.intent.action.MAIN" />
_53
<category android:name="android.intent.category.LAUNCHER" />
_53
</intent-filter>
_53
</activity>
_53
_53
<activity
_53
android:name="com.mirror.sdk.activities.RedirectActivity"
_53
android:exported="true"
_53
>
_53
<intent-filter>
_53
<action android:name="android.intent.action.VIEW"/>
_53
<category android:name="android.intent.category.DEFAULT"/>
_53
<category android:name="android.intent.category.BROWSABLE"/>
_53
<data android:scheme="mwsdk"/>
_53
</intent-filter>
_53
</activity>
_53
</application>
_53
_53
</manifest>

3. Usage

Initialization

We can initialize Mirror World SDK with the following code:

build.gradle
AndroidManifest.xml
InitializeSDK.java
Copy

_6
Activity activity = this;
_6
String apiKey = "your-api-key";
_6
boolean useDebugMode = true;
_6
_6
MirrorWorld.setDebug(useDebugMode);
_6
MirrorWorld.initMirrorWorld(activity,apiKey,MirrorEnv.DevNet);

Guide user to login

Users need to log in to use some MirrorSDK features (or APIs). If you want them to login for the first time or once again, use the following code:

build.gradle
AndroidManifest.xml
InitializeSDK.java
startLogin.java
Copy

_11
MirrorWorld.startLogin(new LoginListener() {
_11
@Override
_11
public void onLoginSuccess() {
_11
Log.i("Mirror","User login success!");
_11
}
_11
_11
@Override
_11
public void onLoginFail() {
_11
Log.i("Mirror","User login failed!");
_11
}
_11
});

Going Further

Great! At this point you're pretty much ready to start doing building with the Android SDK for Mirror World. There are a few things you can do to proceed from here:

Getting Support

If you're stuck or just looking for support, you may also schedule a support call with our team.

Android Integration Guide

This guide will walk you through the setup process for the Mirror World Smart SDK on Android.

1. Create a Developer Account

Create a developer account on the Developer dashboard. Create project and create an API Key. If you already have an API Key, you may skip this step and proceed to the next one.

Import the Mirror World SDK

Notice: The minimum version that SDK requires is Android 4.4.

  1. Download and uncompress Mirror World Android SDK.
  2. Put the mirrorsdk.aar under the libs folder. You may create a libs folder if it doesn't exist under your Project root > app directory.

android-install

  1. Install SDK dependency. In your build.gradle file, please add the Mirror World SDK as a dependency.

2. Configuring CustomTab

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

Add permission for internet

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

Update dependencies

Then add this to your gradle file:

build.gradle
Copy

_1
implementation 'androidx.browser:browser:1.4.0'

Register this activity

If you want to use CustomTab to show content to users (Recommended), you need to configure the following on your AndroidManifest.xml.

Complete Android Manifest

The final file will look something like this:

3. Usage

Initialization

We can initialize Mirror World SDK with the following code:

Guide user to login

Users need to log in to use some MirrorSDK features (or APIs). If you want them to login for the first time or once again, use the following code:

Going Further

Great! At this point you're pretty much ready to start doing building with the Android SDK for Mirror World. There are a few things you can do to proceed from here:

Getting Support

If you're stuck or just looking for support, you may also schedule a support call with our team.

build.gradle
CopyExpandClose

_3
dependencies {
_3
implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
_3
}

Edit this page on GitHub

Copyright © Mirror World, Inc. 2023

Home

Tutorials

Guides

API Reference