Этот коммит содержится в:
Anton Tananaev
2014-01-29 20:31:13 +13:00
родитель 39e126cc6d
Коммит fb3b7658a8
+5
Просмотреть файл
@@ -116,11 +116,16 @@ public class TraccarService extends Service {
wakeLock.release(); wakeLock.release();
} }
@TargetApi(Build.VERSION_CODES.ECLAIR)
public double getBatteryLevel() { public double getBatteryLevel() {
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR) {
Intent batteryIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); Intent batteryIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
return (level * 100.0) / scale; return (level * 100.0) / scale;
} else {
return 0;
}
} }
private PositionProvider.PositionListener positionListener = new PositionProvider.PositionListener() { private PositionProvider.PositionListener positionListener = new PositionProvider.PositionListener() {