The BoneMobile container SDK is an optional module that lets you load plugins. To develop or use plugins, integrate the BoneMobile container SDK into your app.
Dependent SDK | Overview |
API channel | Provides API channel capabilities. |
Since August 1, 2019, Google Play has required that apps support 64-bit architecture. If you want to list your app on Google Play in countries and regions outside the Chinese mainland, including Hong Kong (China), Macao (China), and Taiwan (China), and your app uses the BoneKit SDK, you must upgrade the SDK to ensure your app can be listed. Going forward, new plugins and upgrades to existing plugins will be available only for proprietary apps that use v0.59 or later of the BoneKit SDK.
Initialization
For more information, see SDK initialization.
Usage
Open the plugin panel
// The first parameter is the current context, usually an Activity. // The second parameter is in the format "link://plugin/{Plugin ID}". For more information, see the description of the plugin that you want to open. The following example shows how to open the network configuration plugin for the Chinese mainland. Router.getInstance().toUrl(context, "link://router/connectConfig"); // "link://plugin/a123kfz2KdRdrfYc" is no longer recommended.Open the plugin panel and accept the return value
The following example shows how to call the network configuration plugin and accept the configuration result.
// Start the plugin. Bundle bundle = new Bundle(); bundle.putString("productKey", pk); Router.getInstance().toUrlForResult(activity, "link://router/connectConfig",{your_request_code}, bundle); // Accept the network configuration result. protected void onActivityResult(int requestCode, int resultCode, Intent data) { ... if (REQUEST_CODE_PRODUCT_ADD == requestCode) { if (Activity.RESULT_OK != resultCode) { // Network configuration failed. return; } String productKey = data.getStringExtra("productKey"); String deviceName = data.getStringExtra("deviceName"); // Network configuration successful. } }Open the debug panel
Use the following code to enable the local debug feature.
String ip = "{IP address}"; // The Bone debug service must be enabled on the developer computer. new BoneDevHelper().getBundleInfoAsync(this, ip, new BoneDevHelper.OnBondBundleInfoGetListener() { @Override public void onSuccess(BoneDevHelper.BoneBundleInfo boneBundleInfo) { BoneDevHelper.RouterInfo info = new BoneDevHelper().handleBundleInfo(MainActivity.this, boneBundleInfo); if (null == info) { return; } Router.getInstance().toUrl(MainActivity.this, info.url, info.bundle); } @Override public void onError(String message, Exception e) { Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show(); if (null != e) { e.printStackTrace(); } } });
Integrate account capabilities
If a plugin needs to access information about the current user, such as the logon status or nickname, integrate the account and user SDK and register the API with the container.
For more information about how to integrate the account SDK, see Account and user SDK.
To register the API with the container, use the following code.
BonePluginRegistry.register(BoneUserAccountPlugin.API_NAME, BoneUserAccountPlugin.class);Integrate TSL model features
If a plugin needs to use Thing Specification Language (TSL) model APIs, for example, in a device panel scenario, integrate the TSL model SDK and register the API with the container.
For more information about how to integrate the TSL model SDK, see TSL model SDK.
To register the API with the container, use the following code.
BonePluginRegistry.register("BoneThing", BoneThing.class);Integrate network configuration capabilities
If a plugin needs to use network configuration capabilities, integrate the network configuration SDK and register the API with the container.
For more information about how to integrate the network configuration SDK, see Network configuration SDK.
To register the API, use the following code.
BonePluginRegistry.register("BoneAddDeviceBiz",BoneAddDeviceBiz.class);
BonePluginRegistry.register("BoneLocalDeviceMgr",BoneLocalDeviceMgr.class);
BonePluginRegistry.register("BoneHotspotHelper",BoneHotspotHelper.class);
// To attach a Bluetooth device, add the following code.
BonePluginRegistry.register("BoneThing", BoneThing.class);Integrate persistent connection capabilities
If a plugin needs to subscribe to cloud messages, integrate the persistent connection channel SDK and register the API with the container.
For more information about the persistent connection channel SDK, see Persistent connection channel SDK.
To register the API, use the following code:
BonePluginRegistry.register("BoneChannel", BoneChannel.class);Share configurations between Native and JS
In some scenarios, the native and JavaScript layers may need to share configurations. A configuration area that can be accessed by both is available for this purpose.
To access the configuration area on an Android client, use the following code:
// Set
BoneConfig.set("region", "china");
// Get
String region = BoneConfig.get("region");Support for GIF and WebP
The Android platform does not support the GIF and WebP formats by default. To add support for these formats, add the following libraries.
dependencies {
compile 'com.facebook.fresco:animated-gif:0.11.0' // Add this statement to support GIF animations.
compile 'com.facebook.fresco:webpsupport:0.11.0' // Add this statement to support the WebP format.
compile 'com.facebook.fresco:animated-webp:0.11.0' // Add this statement to support WebP animations.
}Obfuscation configurations
For more information, see Obfuscation configurations.