O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying the status of the device battery levels

Progression in capabilities and processing power means we can do much more with our mobile devices including multitasking and background processes. This often means we end up using more battery power to fuel our applications.

How to do it...

In this recipe, we will build an application to display the connection details and the current power capacity of the device battery:

  1. Firstly, create a new PhoneGap project named batterystatus by running the following:
    phonegap create batterystatus com.myapp.batterystatus batterystatus
    
  2. Add a devices platform. You can choose to use Android, iOS, or both using the following command:
    cordova platform add ios
    cordova platform add android
    
  3. We will use a battery-status ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required