MegaTracker External Sensor Control
By default, MegaTracker automatically manages the listener interfaces for accelerometer and GNSS data. In some complex application scenarios, however, developers may need to manually control whether these interfaces are enabled or disabled for finer-grained power management or permission control.
Before You Begin
- Learn about MegaTracker concepts and workflow
External Control Constraint Logic
When creating MegaTrackerConfigs for a session, you can configure the sensor listener interfaces through MegaTrackerSensorOptions.
| Parameter Name | Type | Default Value | 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 scenario: If your application does not directly subscribe to sensor data except for Mega features, keep the default value false and let Mega handle it automatically.
When the above parameters are set to true, developers must strictly follow the call order below:
- Startup flow
Before calling start(options), you must make sure the corresponding sensor listener has been manually enabled:
Accelerometer: call wx.startAccelerometer.
GNSS: call wx.startLocationUpdate.
Stop flow
Only after calling stop() can you disable the corresponding sensor listener:
Accelerometer: call wx.stopAccelerometer.
GNSS: call wx.stopLocationUpdate.
Caution
Conflict warning: If set to false (managed by Mega), do not call WeChat native sensor stop interfaces while Session is running, otherwise data interruption may occur.
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 enabling and disabling WeChat geolocation data listening. Before calling start(options), call wx.startLocationUpdate to enable WeChat geolocation data listening.