Da Real Fragmentation Explained Codemotion 2016

Da Real Fragmentation Explained Codemotion 2016

Nowadays, fragmentation in Android is a fact. As developers, we have to deal constantly with random behaviors between different versions of the operating system, incomplete ROMs, different hardware qualities, manufacturers that modify the specs of some APIs or even ignore them... That’s “Da real fragmentation” and it makes development much more difficult. In addition, if you have background processes running, your life becomes a nightmare!

In this session we will talk about the problems that we found along the way creating an app which needs to keep track of sensor signals in background. We will review how to deal with the different versions of alarms in Android, how to live with Doze mode and other battery optimization apps and we will show you some hardware and software peculiarities of different manufacturers.

Apart from that, we will explain how we have solved such fragmentation issues in order to develop an app that works properly in as many devices as possible.

Da Real Fragmentation series
Alarms: http://pguardiola.com/blog/darealfragmentation-alarms/
Doze: http://pguardiola.com/blog/darealfragmentation-doze/
Sensors: http://pguardiola.com/blog/darealfragmentation-sensors/
Repository: https://github.com/Guardiola31337/darealfragmentation

3c2bdd16c0ea8511dc254b8497a06f78?s=128

Pablo Guardiola

November 18, 2016
Tweet

Transcript

  1. 3.
  2. 4.
  3. 7.

    ∎ set() API 1 ∎ setExact() API 19 ∎ setWindow()

    API 19 ∎ setRepeating() API 1: Type, trigger time (ms), interval, PendingIntent METHODS
  4. 8.
  5. 9.

    PROBLEM SDK Fragmentation ∎ A bunch of APIs do the

    same ∎ Names of methods almost identical
  6. 13.
  7. 14.

    Alarm Set at mar. ago. 09 13:08:23 CEST 2016 Alarm

    received at mar. ago. 09 13:15:00 CEST 2016 Alarm received at mar. ago. 09 13:15:00 CEST 2016 Alarm received at mar. ago. 09 13:15:41 CEST 2016 Alarm received at mar. ago. 09 13:20:41 CEST 2016 Alarm received at mar. ago. 09 13:25:40 CEST 2016 Alarm received at mar. ago. 09 13:30:41 CEST 2016 Alarm received at mar. ago. 09 13:30:41 CEST 2016 Alarm received at mar. ago. 09 13:35:41 CEST 2016 Xiaomi Redmi Note 2
  8. 16.
  9. 19.

    FRAMEWORK SensorManager ∎ Instance sensor service ∎ Access and list

    sensors ∎ Register/Unregister listeners ∎ Data acquisition rates ∎ Sensor accuracy constants ∎ Acquire orientation
  10. 25.
  11. 27.
  12. 31.
  13. 34.
  14. 38.
  15. 41.
  16. 42.
  17. 45.
  18. 58.
  19. 60.
  20. 61.
  21. 62.

    APP STANDBY API 23+ ∎ User not using the app

    ∎ App not in foreground ∎ No notifications
  22. 66.

    PROBLEM ALARMS Alarms methods of Android 5.1- when in Doze

    (Android 6.0+ devices) WON’T work properly
  23. 75.
  24. 77.

    References ∎ Da Real Fragmentation series (http://pguardiola.com) ∎ Da Real

    Fragmentation GitHub repository (https://github.com/Guardiola31337/darealfragmentation) ∎ Presentation template by SlidesCarnival