Tag Archives: Android O

How to Optimize GPS and Background Processes for Android Oreo

As our past article Android Oreo Serves Up the Sweets will show, Android Oreo lived up to expectations upon release and gave both consumers and app developers plenty of enhancements to enjoy.

However, for app developers, enhancements to the UI aimed to conserve battery life affect GPS services and require changes to the code in order to optimize pre-existing apps for the new OS. Specifically, Android Oreo restricts apps that are running in the background with limited access to background services. Additionally, apps can no longer use their manifests to register for most implicit broadcasts. When an app is in the background, it is given several minutes to create and use services, but at the end of that time slot, the app is considered idle and the OS will stop running background services.

These changes directly affect apps with geolocation functionality. Android Oreo limits how frequently apps can gather location in the background. Background apps can only receive location updates a few times each hour. The APIs affected due to these limits include Fused Location Provider, Geofencing, Location Manager, Wifi Manager, GNSS Measurements and GNSS Navigation Messages.

Apps that currently use location services in previous Android OS’s will require an update to optimize for Android Oreo. Apps that use location services range anywhere from navigational apps like Waze and Google Maps to social media apps like Twitter, and food apps like Yelp and Seamless.

For apps that require frequent location updates, increasing the usage of the app in the foreground will ensure that the app gets frequent access to location information. In order to program this, developers must implement startServiceinForeground() instead of startService() in Activity class.

In Service class in onStartCommand(), developers can use the following code:

Screen Shot 2018-05-07 at 12.46.57 PM

Via StackOverflow

When foreground services running in the background consume high energy, Oreo fires an automatic push notification to the user informing them of the battery-consuming service. With the push notification in place, app users are more likely to uninstall apps that track location without conserving battery life, putting the onus on software developers to deliver battery-efficient apps. One of the biggest issues facing some app developers is ensuring that battery life is not sucked as a result of tracking location in apps. Check out our full rundown of how to build battery-efficient geolocation apps for supplementary reading.

The results of the limits put in place with Android O are increased battery life for the user and the necessity for app owners to consider how their apps interact with location information. Retaining a thorough understanding of how location information will be retrieved and used through out the development process ultimately benefits both software developers and consumers with better UI and more energy efficient processes.

Android O: What Google’s Latest OS Offers App Developers

On March 21st, Google unveiled the developer preview for the latest version of the largest OS in the world: Android O. For consumers, it means improved UI, design, battery life, & more. For app developers, it has far deeper implications. With release anticipated in Q3 2017, here is our rundown of the top takeaways about Android O for Android developers:

BATTERY LIFE

The main focus of Android O appears to be to continue Android Nougat’s initiative to reduce battery life. The OS will limit and manage what launched apps can do in the background when multiple apps are open. For example, if a user has a geolocation app open in the background while using another app, location updates will happen less frequently for the background app.

In technical terms, background execution & location limits have been reigned in, allowing the OS to better manage background activity. Background apps are defined by Google as apps showing no visible activity, no foreground service & not connected to a foreground app through its services. Location changes affect the following APIs:

  • Fused Location Provider (FLP): The local system service computes a new location for background apps only a few times each hour, according to the interval defined in the Android O behavior change. Foreground apps will not experience location sampling rates in relation to Android 7.1.1 (API level 25).
  • Geofencing: Background apps can receive geofencing transition events more frequently than from FLP.
  • GNSS Measurements: Callbacks registered to receive outputs from GnssMeasurement and GnssNavigationMessage will stop executing for background apps.
  • Location Manager: Location updates will be provided to background apps only a few times per hour according to the interval defined in the Android O behavior change.

NOTIFICATION CHANNELS

Android OS’s have always thrived in the notification department. Android O allows developers to group notifications into channels. Developers must select a channel for each distinct type of notification they send with the goal of making things easier and more customizable for the user. For example, a user can turn off the “Sports” notification channel from the New York Times app if they are already getting sports notifications from the ESPN app.

Developers can also allow user behavior to dictate notification channels. For example, the developer of a messaging app can create separate notification channels for each of a user’s messaging threads.

WI-FI AWARE

Wi-Fi Aware, or Neighbor Awareness Network (NAN), allows devices to discover and connect directly with each other without any other connectivity between them, like Wi-Fi Access Point or Cellular. Two phones can connect with each other with NAN and share data at high speeds without any additional apps or configuration, opening up tons of possibilities for developers.

Learn more about Wi-Fi Aware:

HI-FI BLUETOOTH AUDIO

Android O supports Hi-Fi Bluetooth audio. While the quality of the audio still depends on the speaker or headphone through which one listens, this is a major improvement for music lovers.

ADAPTIVE ICONS

Android O will introduce adaptive launcher icons. Adaptive icons support visual effects and can display a variety of shapes across different device models. Adaptive icons are a major tool for developers to guide the user’s eye and enhance UX. Check out Android’s developer site to learn more.

RELEASE SCHEDULE

via Android Developers
via Android Developers

The O Developer preview will run from March 21st to the final Android O public release anticipated in Q3 2017. Android will provide incremental updates in mid-May, June, & July. Until Q3 2017, the onus is on Android developers to prepare their future and existing apps for the latest operating system.