Your app can call the SetHandoverMode API to change the network handover mode between delegation mode and proactive mode. The delegation mode is used by default. In this case, your app can call the SetHandoverMode API to set the mode to proactive mode, forbidding the device to initiate handovers by itself. However, in some cases, for example, when the app is switched to the background, the device may still initiate network handovers even if the API is called.
For details about the APIs, please refer to API Reference.
| API | Description |
|---|---|
| int32_t HMS_NetworkBoost_SetHandoverMode(NetworkBoost_HandoverMode mode) | Sets the network handover mode for your app. The delegation mode is used by default. |
Import the Network Boost Kit module.
#include "NetworkBoostKit/network_boost_handover.h" #include <cstdio>
Add the following library to the CMakeLists.txt file. For details, please refer to Preparations for C API Development.
libnetwork_boost.so
Call the SetHandoverMode API to set the mode to proactive mode, forbidding the device to initiate handovers by itself.
int32_t SetHandoverMode()
{
NetworkBoost_HandoverMode mode = NB_MODE_DISCRETION;
int32_t ret = HMS_NetworkBoost_SetHandoverMode(mode);
printf("Network handover mode setting result: %d\n", ret);
return ret;
}