General SDK

更新时间:
复制 MD 格式

The general SDK initializes and configures all other SDKs. You can use it to set the language, country, and other global settings.

Initialization

For more information, see SDK initialization.

Set the country

  1. Display the country and region list page

    • Call the default page

      IoTSmart.showCountryList(final ICountrySelectCallBack callBack);
    • Custom UI Page

      IoTSmart.getCountryList(final ICountryListGetCallBack callback);
  2. Set the country

    IoTSmart.setCountry(Country country, ICountrySetCallBack callBack);
    IoTSmart.setCountry(String domainAbbreviation, ICountrySetCallBack callBack);
    Note

    When the app switches between the Chinese mainland and other regions, note the following:

    • If you use an SDK of API Level 9 or later, you do not need to switch the security image or restart the app.

    • If you use an SDK of API Level 8 or earlier, you must switch the security image and restart the app to ensure that the initialization succeeds.

Configure multiple languages

IoT Platform currently supports 14 languages: Chinese (zh-CN), English (en-US), French (fr-FR), German (de-DE), Japanese (ja-JP), Korean (ko-KR), Spanish (es-ES), Russian (ru-RU), Italian (it-IT), Hindi (hi-IN), Portuguese (pt-PT), Polish (pl-PL), Dutch (nl-NL), and Hungarian (hu-HU).

  • Set the language

    Switches the language environment for all SDKs, such as the API gateway, user account, push notification, and plugin SDKs.

    IoTSmart.setLanguage(String languagename);
  • Get the current language

    Retrieves the language environment of all SDKs, such as the API gateway, user account, push notification, and plugin SDKs.

    IoTSmart.getLanguage(String languageName);
    // Returns the language that is set for the SDK. If no language is set, this method returns the current system language.

Debug unreleased products

Sets the product scope for the device provisioning list in the app. The following values are valid:

  • PRODUCT_SCOPE_ALL: Includes all published and unpublished products in the current project.

  • PRODUCT_SCOPE_PUBLISHED: Includes only published products. For an app released to production, set this parameter to PRODUCT_SCOPE_PUBLISHED.

IoTSmart.setProductScope(String productScope);

Configure logging

Sets the logging status. Valid values are:

  • true: Displays all logs.

  • false: Displays only error logs.

IoTSmart.setDebug(boolean debug);

Get the ID of the connected server

If your app can connect to multiple business servers, you can optimize the user experience by selecting a server based on the current logon server. Call the following API to retrieve the server ID of the current connection. This ID helps you select a region that provides the fastest connection for other business servers.

IoTSmart.getShortRegionId()
Note
  • This API is available in SDK version 0.1.7.1 and later. To upgrade, use the following code:

    com.aliyun.iot.aep.sdk:sdk-framework:0.1.7.1
  • Call this API only after the app is logged on. Otherwise, you cannot retrieve an accurate server ID.

The platform returns the following server ID values:

  • 0: China (Shanghai)

  • 1: Singapore

  • 3: US (Virginia)

  • 4: Germany (Frankfurt)

SDK API reference

For details about the APIs in the IoT Platform SDK, see the SDK API Reference.