All Products
Search
Document Center

Quick start

Last Updated: May 25, 2022

This topic describes how to add the Upgrade SDK related to the release management. After adding the SDK and complete the necessary configurations, you can release a new version of an App is released in the mPaaS console, and the client can detect the new version through the upgrade API and remind users to download and upgrade.

Currently, Upgrade SDK supports access through Native AAR, mPaaS Inside, and Portal & Bundle.

The complete access process mainly includes the following 4 steps:

  1. Add SDK

  2. Configure project

  3. Initialize mPaaS (only required for Native AAR and mPaaS Inside)

  4. Check for update

Prerequisites

Add SDK

Native AAR mode

Follow the instructions in AAR component management to install the UPGRADE component in the project through Component management (AAR).

mPaaS Inside mode

Install the UPGRADE component in the project through Component management (AAR).

For more information, see Manage component dependencies > Add/delete component dependencies.

Componentized access mode

Install the UPGRADE component in the Portal and Bundle projects through Component management (AAR).

For more information, see Manage component dependencies > Add/delete component dependencies.

Configure project

Configure AndroidManifest

  1. Add the following permissions in the AndroidManifest.xml file.

     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  2. Add the following configuration in the AndroidManifest.xml file:

     <provider
     android:name="android.support.v4.content.FileProvider"
     android:authorities="${applicationId}.fileprovider"
     android:exported="false"
     android:grantUriPermissions="true">
     <meta-data
      android:name="android.support.FILE_PROVIDER_PATHS"
      android:resource="@xml/file_paths" />
     </provider>
    Note

    For more information about the configuration of AndroidManifest.xml, please see App Manifest Overview.

  3. Create the file_paths.xml file in the src/main/res/xml directory in the main module of the Portal project with the following content:

     <?xml version="1.0" encoding="utf-8"?>
     <resources>
     <paths>
      <external-files-path
          name="download"
          path="com.alipay.android.phone.aliupgrade/downloads" />
      <external-path
          name="download_sdcard"
          path="ExtDataTunnel/files/com.alipay.android.phone.aliupgrade/downloads" />
     </paths>
     </resources>

Add resources

If you access the UPGRADE SDK through mPaaS Inside or Native AAR, you need to add the following resources to your App, otherwise, the upgrade component will not work. Click here to get the resource file.

Merge the content of strings.xml, styles.xml, and colors.xml under the values directory.

Initialize mPaaS

If you access the UPGRADE SDK through Native AAR or mPaaS Inside, you must initialize mPaaS.

Add the following codes in the object Application:

public class MyApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        // Set mPaaS initialization callback
        QuinoxlessFramework.setup(this, new IInitCallback() {
            @Override
            public void onPostInit() {
                // This callback indicates that mPaaS initialization has been done, and relevant mPaaS calls can be performed here
            }
        });
    }

    @Override
    public void onCreate() {
        super.onCreate();
        // Initialize mPaaS
        QuinoxlessFramework.init();
    }
}

Check for update

Quickly check for an update, and only the checking result is returned.

MPUpgrade mMPUpgrade = new MPUpgrade();
//  The synchronization method, which is called in a subthread.
int result = mMPUpgrade.fastCheckHasNewVersion();
if (result == UpgradeConstants.HAS_NEW_VERSION) {
  // New version available
} else if (result == UpgradeConstants.HAS_NO_NEW_VERSION) {
  // No new version available
} else if (result == UpgradeConstants.HAS_SOME_ERROR) {
  // Error
}