Wpis z mikrobloga

#programowanie #java #android #kotlin

Mam pytanie,zajalem sie pisaniem aplikacji ktora zbiera kroki dzialajac jako Services. Poniewaz od Androida 9.0

Sensors that use the continuous reporting mode, such as accelerometers and gyroscopes, don't receive events.
Nie moge w takim razie zaimplementowac SensorEventListener
https://developer.android.com/about/versions/pie/android-9.0-changes-all
https://stackoverflow.com/questions/55044970/sensor-event-listener-not-working-in-background-service

W jaki sposob dziala takie Samsung Health wiec?
  • 1
  • Odpowiedz
@yras8: Użyj Foreground Service. Z pierwszego linka:

If your app needs to detect sensor events on devices running Android 9, use a foreground service.
W dokumentacji sensorów jest też informacja

Given these restrictions, it's best to detect sensor events either when your app is in the foreground or as part of a
  • Odpowiedz