How to Optimize Android Phone Battery - PowerPoint PPT Presentation

About This Presentation
Title:

How to Optimize Android Phone Battery

Description:

The limitation of resources on mobile raise challenges for app developers majorly on battery consumption. This has led to concern and developers are continuously searching methods and tools to resolve the issue of optimizing energy consumption for the app. – PowerPoint PPT presentation

Number of Views:188

less

Transcript and Presenter's Notes

Title: How to Optimize Android Phone Battery


1
Battery Optimization Android Apps
  • With Best Practices for Zero Compromise on
  • Performance

2

JOB Scheduler API
  • For efficient use of android resources and
    smartly handles background tasks in a manner to
    improve battery life also.
  • As it operates at the system level hence capable
    of smartly scheduling background task to run
    along with jobs from other apps hence minimizes
    radio usage a major battery drainage issue.
  • It doesnt perform task based on time but based
    on condition.

3
JOB Scheduler API
4

JOB Scheduler API Code Snippet
5
Android Doze
  • When smartphone is kept idle for hours usually
    during night with screen off and the device is
    stationary, this might drain some battery.
  • Now android doze is triggered and it will defer
    the background tasks, syncs, alarms and Wi-Fi
    scan until a maintenance window is scheduled.
  • Doze will batch all background activities inside
    a single batch to extend battery life by good
    margin.

6
Android Doze
7
Android Doze Extended
  • When device is in pocket (not stationary) with
    screen off.
  • the lighter doze version will be active and
    restrict lesser number of background tasks.
  • During this time there will be regular
    maintenance windows.

8

Android Doze Extended
9
Doze Modes Comparison
  • Extended doze mode produce maintenance window at
    short interval to ensure apps are ready when user
    wants to use the device again.

10
Doze Optimization
  • High Priority GSM messages are the best method to
    deliver the time critical messages to the app. It
    enables app to access the network to ensure
    important notifications reach the user
  • Foreground services will continue to work despite
    the ongoing battery optimization.

11
Doze Optimization
  • Whether the smartphone is stationary or not, when
    the screen is off for a while means user isnt
    engaged with the device and that is an
    opportunity to conserve the battery power.

12
App Standby
  • App Standby is designed to limit the background
    syncs and tasks for apps that user isnt
    interested at the moment.

13
App Standby
14
Monitoring the Battery Level and Charging State
  • It is good practise to notice battery level and
    charging state before performing application
    update. If the device is charging over AC(wall
    charger) refresh rate can be maximised without
    affecting battery life. In case device is
    unplugged limiting the update rate will help in
    maximising battery life.

15
Monitoring the Battery Level and Charging State
16
Code Snippet to determine Charging State and
Method
  • // Are we charging / charged?
  • int status batteryStatus.getIntExtra(BatteryMana
    ger.EXTRA_STATUS, -1)
  • boolean isCharging status BatteryManager.BATT
    ERY_STATUS_CHARGING
  • status BatteryManager.BATT
    ERY_STATUS_FULL
  • // How are we charging?
  • int chargePlug batteryStatus.getIntExtra(Battery
    Manager.EXTRA_PLUGGED, -1)
  • boolean usbCharge chargePlug
    BatteryManager.BATTERY_PLUGGED_USB
  • boolean acCharge chargePlug
    BatteryManager.BATTERY_PLUGGED_AC

17
Monitor Connectivity State to Limit Battery Drain
  • Background services schedule updates to an
    application. They do it on behalf of internet
    resources and cache data.
  • This schedule can negatively impact battery life
    takes place especially during no internet state
    or weak internet connection.
  • You can handle this tricky situation smartly by
    knowing the device connectivity status with
    connectivity manager

18
Monitor Connectivity State to Limit Battery Drain
  • Connectivity manager will also help in decoding
    the connection category and accordingly you can
    decide either to continue with an update to the
    application or restrict it now.
  • Connectivity manager code snippet to query the
    active network and subsequent internet
    connectivity.
  • ConnectivityManager cm
  • (ConnectivityManager)context.getSystemServ
    ice(Context.CONNECTIVITY_SERVICE)
  • NetworkInfo activeNetwork cm.getActiveNetworkInf
    o()
  • boolean isConnected activeNetwork ! null
  • activeNetwork.isConnectedOrC
    onnecting()

19
Key Steps required to Minimize Server Updates and
Optimize the Battery Drain
  • An Android application needs to activate the
    wireless radio and create the connection to check
    the available updates on the server. This will
    cause unnecessary battery drain.
  • Once we understand the device state, network
    connectivity and user behavior then accordingly
    periodic update can be scheduled.

20
Key Steps to Minimize Server Updates and Optimize
the Battery Drain
21
Key Steps required to Minimize Server Updates and
Optimize the Battery Drain
  • Google Cloud Messaging A mobile notification
    service via which server will notify the
    application when data is available for download.
    All apps which require periodic updates from a
    remote server can utilise this service which
    ensure update notifications to the app are
    carried out using single GCM connection. This
    approach will reduce unnecessary connections to
    check for periodic updates as a new connection is
    created only when an update is available

22
Key Steps to Minimize Server Updates and Optimize
the Battery Drain
  • Set the frequency to minimum Another way to
    optimize is to set the update frequency as low
    as possible at the same time ensuring zero
    negative impact on user experience. This will
    make the best balance between battery usage and
    data updates.
  • Inexact Repeating Alarms If multiple alarms are
    set to go off around the same time then android
    can phase shift the alarm fire time for various
    application in a manner that all these apps will
    receive the alarm at the same time. This will
    allow all applications to perform network updates
    with a single

23
Key Steps to Minimize Server Updates and Optimize
the Battery Drain
  • activation of wireless radio.
  • Exponential back-off methods In this method
    updates are scheduled after close monitoring the
    app usage and reduce update frequency
    dynamically, generally frequency is reduced for
    the apps which have not been used after the last
    update.
  • HTTP Cache and HTTP Response Cache This
    technique is used to avoid downloading duplicate
    files by keeping them in case. Such files once
    stored inside case directory thereby, eliminating
    the need to download it every time

24
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com