[Huawei Developers] Freemind R:
For more articles like this, you can visit HUAWEI Developer Forum and Medium.​

[IMG="https://miro.medium.com/max/1400/1*PIxl0fyYeboHS3VkuL987A.jpeg"]https://miro.medium.com/max/1400/1*PIxl0fyYeboHS3VkuL987A.jpeg[/IMG]​

Hello there, in this article I will try to explain what is and how to integrate HUAWEI App Multiplier. You can find the demo project source and official guides at the very end of the article.

What is Huawei App Multiplier

App Multiplier is a system-side solution that splits the screen on an activity base. You can significantly improve user experiences thanks to App Multiplier and provide a magic view for your applications on new generation Android devices.

What type of display modes App Multiplier provides?

App Multiplier provides three dual-window display modes which are Shopping, Navigation bar and Custom modes to meet users’ requirements in different scenarios.

[IMG="https://miro.medium.com/max/210/1*Syr05q3UQ6oKkgevgZE78g.png"]https://miro.medium.com/max/210/1*Syr05q3UQ6oKkgevgZE78g.png[/IMG]

Shopping mode:

Shopping display mode is applicable to shopping apps, allowing users to quickly compare product specs, such as the price. Screen shows recently viewed windows, with the latest one on the right and the second latest one on the left.

Any window opened on the left screen will replace the original content on the right screen. When a new window is opened on the right screen, it will display on the right, while the original content displaying on the right will move to the left

When the user touches the back key on the left screen, both the Activity of the right screen and the Activity at the top of the stack on the left screen are destroyed.

Navigation bar mode:

The left screen always displays the app home screen, and the right screen displays the content based on operations on the left screen.

Custom mode:

In this mode, developers can customize how the windows display by defining the activity pairs.

In full screen mode, the Activities that meet the activityPairs rules will trigger split-screen display.

If a new Activity that doesn’t meet the activityPairs rules is triggered in a split-screen scenario, it will display on the right screen, wherever it is triggered.

If a new Activity that meets the activityPairs rules is triggered in a split-screen scenario, the screen will display as follows:

When the Activity is triggered from the left screen, it will replace the right screen.

When the activity is triggered from the right screen, it will display on the right, while the original right screen goes to the left.

When the user touches the back key on the left screen, all Activities of the right screen are destroyed, and the stack top Activity of the left screen is also destroyed.

How to integrate App Multiplier?

You just need to simple few lines configuration code to be added to the app’s configuration file.

Let’s make the app magical!

Notice: If your app is released in AppGallery for the first time, you need to register a HUAWEI ID and create an app in AppGalley Connect. Please, refer to Register a HUAWEI ID for registration, and Preparations for Integrating HUAWEI HMS Core for creating an app.

Create your activity pages, and generate triggering relationships between the pages. In this demo example,

Contacts and Email can be opened from the MainActivity.

FavoriteContacts can be opened from Contacts.

Inbox and JunkEmail can be opened from Email.

Firstly, add the meta-data into application in the AndroidManifest.xml file.

<meta-data android:name=”EasyGoClient” android:value=”true” />

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

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

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Contacts" />
<activity android:name=".Email" />
<activity android:name=".FavoriteContacts" />
<activity android:name=".Inbox" />
<activity android:name=".JunkEmail" />

<meta-data android:name="EasyGoClient" android:value="true" />
</application>

</manifest>

Next, create a JSON configuration file named easygo.json in the assets folder.

Notice: Assets folder is not be created automatically when you create a project. You need to create it manually. Use the following way to create assets folder.

Click on File →New →Folder →Assets Folder.

The default folder location is src/main/assets. Keep as it is, then click on Finish.

You can use the file as template. Please, don’t forget to modify activities and package names.

{
"easyGoVersion": "1.0",
"client": "com.hayriaral.appmultiplierexample",
"logicEntities": [
{
"head": {
"function": "magicwindow",
"required": "true"
},
"body": {
"mode": "1",
"activityPairs": [
{
"from": "com.hayriaral.appmultiplierexample.MainActivity",
"to": "*"
},
{
"from": "com.hayriaral.appmultiplierexample.Contacts",
"to": "com.hayriaral.appmultiplierexample.FavoriteContacts"
},
{
"from": "com.hayriaral.appmultiplierexample.Email",
"to": "com.hayriaral.appmultiplierexample.Inbox"
},
{
"from": "com.hayriaral.appmultiplierexample.Email",
"to": "com.hayriaral.appmultiplierexample.JunkEmail"
}
],
"transActivities": [
]
}
}
]
}

Let me describe these parameters:

easyGoVersion	: This parameter has a fixed value of 1.0.
client	: App package name.
logicEntities.head.function	: This parameter has a fixed value of magicwindow.
logicEntities.head.required	: This parameter has a fixed value of true.
logicEntities.body.mode	: 0 for Shopping mode, 1 for Custom and Navigation bar mode.
logicEntities.body.activityPairs.from	: Source activity that triggers screen splitting.
logicEntities.body.activityPairs.to	: Target Activity that triggers screen splitting. * indicates any activity.

That’s it! Your application is set ready for new generation devices.

How to check how it works without having a supported device?

Just as I did, you can use HUAWEI Cloud Debugging Service. Please, follow the guide to use the service.

[IMG="https://miro.medium.com/max/1374/1*eMvAHa1-LT0xFaqfzva6sQ.gif"]https://miro.medium.com/max/1374/1*eMvAHa1-LT0xFaqfzva6sQ.gif[/IMG]

On which devices are App Multiplier supported?

App Multiplier is supported on HUAWEI foldable devices like HUAWEI Mate Xs, and HUAWEI MediaPad M6 series and later tablets running EMUI 10.X or later.

I hope this article will help you for using App Multiplier. See you in next article.

References:

Source code: App Multiplier Example

Official App Multiplier Development Guide: App Multiplier Development Guide