MegaTracker sensor external control
By default, MegaTracker automatically manages the listening interfaces for accelerometer and GNSS data. However, in certain complex application scenarios, developers may need to manually control the activation and deactivation of these interfaces to achieve more refined power management or permission control.
Before you begin
- Understand MegaTracker concepts and workflow
External control constraint logic
When creating a session MegaTrackerConfigs, you can configure the sensor listening interfaces via MegaTrackerSensorOptions.
| Parameter | Type | Default | Description |
|---|---|---|---|
| isAcceExternalControl | boolean |
false |
Whether the accelerometer is controlled externally (by the developer). |
| isGeoExternalControl | boolean |
false |
Whether GNSS data is controlled externally (by the developer). |
Tip
Applicable scenarios: If your application does not directly subscribe to sensor data apart from Mega functionality, it is recommended to keep the default value false and let Mega handle it automatically.
When the above parameters are set to true, developers must strictly adhere to the following calling sequence:
- Startup process
Before calling start(options), ensure that the corresponding sensor listening is manually activated:
Accelerometer: Call wx.startAccelerometer.
GNSS: Call wx.startLocationUpdate.
Shutdown process
After calling stop(), you can deactivate the corresponding sensor listening:
Accelerometer: Call wx.stopAccelerometer.
GNSS: Call wx.stopLocationUpdate.
Caution
Conflict warning: If set to false (Mega-managed), do not call the native WeChat sensor deactivation interfaces during the session runtime, as this will cause data interruption.
const megaTrackerSensorOptions: easyar.MegaTrackerSensorOptions = {
isAcceExternalControl: false,
isGeoExternalControl: true
};
const megaTrackerConfigs: easyar.MegaTrackerConfigs = {
access: apiKeyAccess,
options: megaTrackerSensorOptions
};
session = megaComponent.createSession(megaTrackerConfigs);
This example demonstrates how to externally control the activation and deactivation of WeChat location data listening. Before calling start(options), you need to call wx.startLocationUpdate to activate WeChat location data listening.