Hello, I have develop quite complex app that measure your BPM, your inactivity (via gyroscope), your GPS position and GSM signal strenght. After few tests, my app is working aprox. 7.5 hours till battery dead. I need to increase to 8-9 hours.
My first test setup: GPS localization every 1 minute, GSM strenght every 1 minute, BPM measure every 1 seconds. Wifi+LTE always on, display brightness 60%. ==> 7.5 hours
My second test setup: GPS every 2 minutes, GSM every 2 minutes, BPM measure every 30 seconds, WIFI+LTE always on, display brightness 60%. Result is the same. 7.5 hours.
SO. I think, that even I set GPS, GSM, BPM for 1 or 5minutes, sensors are “always on” (if you understand me).
This is how I did it:
public void CheckingGPSPosition()
{
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
{
_gps_seconds--;
if (_gps_seconds == 0)
{
_gps_seconds = 120;
GetActualGPS();
}
return _isTimerStart;
});
}
Is this correct…? After 120 seconds this function call GetActualGPS function:
public async void GetActualGPS()
{
try
{
Tizen.Location.Locator locator;
locator = new Locator(LocationType.Hybrid); // .Gps
Tizen.Location.Location location = locator.GetLocation();
if (location != null)
{
gps_location_latitude = location.Latitude.ToString().Replace(",", ".");
gps_location_longtitude = location.Longitude.ToString().Replace(",", ".");
Preferences.Set("location_latitude", gps_location_latitude);
Preferences.Set("location_longlitude", gps_location_longtitude);
}
else
{
await DisplayAlert("0", "location is null", "OK");
}
}
catch (Exception ex)
{
await DisplayAlert("Unable to get location", ex.Message, "OK");
}
}
And BPM like this, I set monitor.Interal to 30000 (30 seconds). But I am not sure, If it is right.
private void OnPrivilegesGranted()
{
_monitor = new HeartRateMonitor();
_monitor.Interval = 30000;
_monitor.PausePolicy = SensorPausePolicy.None;
StartMeasurement();
}
private void StartMeasurement()
{
_monitor.DataUpdated += OnMonitorDataUpdated;
_monitor.Start();
}
private void OnMonitorDataUpdated(object sender, HeartRateMonitorDataUpdatedEventArgs e)
{
hrValue.Text = e.HeartRate > 0 ? e.HeartRate.ToString() : "0";
}
I also have a small ElottieAnimation JSON - heartbeat. But in 90% my app is not visible, sensors working in background.