Reader small image

You're reading from  Android Wear Projects

Product typeBook
Published inJul 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787123229
Edition1st Edition
Languages
Right arrow
Author (1)
Ashok Kumar S
Ashok Kumar S
author image
Ashok Kumar S

Ashok Kumar S has been working in the mobile development domain from about eight years. He is a Google certified engineer, speaker at global scale conferences and he also runs a youtube channel (AndroidABCD) for Android developers. He is an early Firebase adopter since before Google acquired Firebase. He is Computer Science and Engineering graduate who is completely passionate about innovation in technology. He contributes to open source heavily to improve his e-karma. Ashok has also written a book on Wear OS programming through a project approach.
Read more about Ashok Kumar S

Right arrow

Keeping your application active on a Wear device


When we write an application for contexts, we need to do certain alternatives. We know that when not using the application, we should make that app to sleep in Wear devices for better battery performance, but when we are building an application for maps, it is necessary that maps be visible and active for the user.

Android has a simple configuration for this: a method with few lines that activates the ambient mode:

//oncreate Method
setAmbientEnabled();

This starts the ambient mode on the map. The API swaps to a non-interactive and low-color rendering of the map when the user is no longer actively using the app:

@Override
public void onEnterAmbient(Bundle ambientDetails) {
    super.onEnterAmbient(ambientDetails);
    mMapFragment.onEnterAmbient(ambientDetails);
}

The following code exits the ambient mode on the WearMap. The API swaps to the normal rendering of the map when the user starts actively using the app:

@Override
public void onEnterAmbient...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Android Wear Projects
Published in: Jul 2017Publisher: PacktISBN-13: 9781787123229

Author (1)

author image
Ashok Kumar S

Ashok Kumar S has been working in the mobile development domain from about eight years. He is a Google certified engineer, speaker at global scale conferences and he also runs a youtube channel (AndroidABCD) for Android developers. He is an early Firebase adopter since before Google acquired Firebase. He is Computer Science and Engineering graduate who is completely passionate about innovation in technology. He contributes to open source heavily to improve his e-karma. Ashok has also written a book on Wear OS programming through a project approach.
Read more about Ashok Kumar S