Your app can call the setHandoverMode API to change the network handover mode between delegation mode and proactive mode.
For details about the APIs, please refer to API Reference.
| API | Description |
|---|---|
| setHandoverMode(mode: HandoverMode): void | Sets the network handover mode for your app. The delegation mode is used by default. |
Import the Network Boost Kit module.
import { netHandover} from '@kit.NetworkBoostKit';
import { BusinessError } from '@kit.BasicServicesKit'; Call the setHandoverMode API to set the mode to proactive mode, forbidding the device to initiate handovers by itself.
try{
let mode: netHandover.HandoverMode = netHandover.HandoverMode.DISCRETION;
netHandover.setHandoverMode(mode);
} catch (err) {
console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
}