Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Pablo Guardiola

November 18, 2016
Tweet

More Decks by Pablo Guardiola

Other Decks in Programming

Transcript

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

    API 19 ∎ setRepeating() API 1: Type, trigger time (ms), interval, PendingIntent METHODS
  2. PROBLEM SDK Fragmentation ∎ A bunch of APIs do the

    same ∎ Names of methods almost identical
  3. 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
  4. FRAMEWORK SensorManager ∎ Instance sensor service ∎ Access and list

    sensors ∎ Register/Unregister listeners ∎ Data acquisition rates ∎ Sensor accuracy constants ∎ Acquire orientation
  5. APP STANDBY API 23+ ∎ User not using the app

    ∎ App not in foreground ∎ No notifications
  6. PROBLEM ALARMS Alarms methods of Android 5.1- when in Doze

    (Android 6.0+ devices) WON’T work properly
  7. References ∎ Da Real Fragmentation series (http://pguardiola.com) ∎ Da Real

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