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

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

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

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

Update dependencies

Then add this to your gradle file:

build.gradle
Copy

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

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

Complete Android Manifest

The final file will look something like this:

build.gradle
AndroidManifest.xml
Copy

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

3. Usage

Choose your chain

Developers must use specified classes to call APIs on specified chains.
For example, if they want to call init API on the BNB chain, they must call MWEVM.initSDK().

And this is their correspondence:

  • Solana
  • Ethereum
  • Polygon
  • BNB Chain

In the following documents, we will use Solana chain to show how to use Mirror SDK.

Initialization

We can initialize Mirror World SDK with the following code:

build.gradle
AndroidManifest.xml
InitializeSDK.java
Copy

Context context = this;
String apiKey = "your-api-key";
MirrorEnv env = MirrorEnv.DevNet;
MWSolana.initSDK(context,apiKey,env);

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

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

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

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

Choose your chain

Developers must use specified classes to call APIs on specified chains.
For example, if they want to call init API on the BNB chain, they must call MWEVM.initSDK().

And this is their correspondence:

  • Solana
  • Ethereum
  • Polygon
  • BNB Chain

In the following documents, we will use Solana chain to show how to use Mirror SDK.

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

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

Edit this page on GitHub

Copyright © Mirror World, Inc. 2023

Home

Integration

Guides

API Reference