1161 Android Performance Patterns: Battery Performance 101
Android Performance Patterns: Battery Performance 101

Android Performance Patterns: Battery Performance 101

❤ 530 , Категория: Новости,   ⚑ 16 Авг 2017г



Battery is the most precious resource to Android users right now. The world is more mobile, but it’s frustrating when you can’t make it through a full day without needing to recharge your phone. And Sadly, for most developers, Battery Efficiency is the last thing on their minds.

In this video +Colt McAnlis introduces the basic concepts of Battery Performance on android, and points out a few simple pitfalls to avoid while writing your application.

Watch more Android Performance Patterns here: http://goo.gl/3dBbse

Full Video Transcript:

Battery’s the most precious
resource to Android users right now.

The world is more mobile,
but it’s frustrating when you can’t make
it through the day without needing a
recharge of your phone.

And sadly for most
developers, battery efficiency is the last thing
on their minds.

My name is Colt McAnlis
canvas and the truth is that your app doesn’t
have to be a battery hog.

With a few simple
APIs and tools you can have a fast, awesome
application that users love.

But let’s take a step
back for a second.

How bad is the state of
battery usage right now?

Well, Purdue University did a
study of the top apps and games for mobile devices, in which
they measured the battery draw of various
types of actions.

They made a shocking discovery.

On average, only
about 25% to 30% of the battery used
by these applications was dedicated to the core
functions of the app,like drawing images, laying
out news, or throwing birds across the screen.

The other 75% completely eaten up by uploading analytics,
checking location, and constantly polling the
server for ads to display.

This finding presents
an interesting problem for developers.

See, these applications
are effectively eating up their users’
battery for their benefit while only providing marginal
features to the users, which is tricky since at
the end of the day the user’s happiness
is directly linked to the success of
the application.

Smart developers
will focus on finding a balance between
these two extremes by recognizing that they
can perform the same actions and draw less battery
at the same time.

For example, waking up
the device from sleep has a battery cost
associated with it.

So conservative
use of wake locks, or rather smarter
use of wake locks, can help reduce battery drain.

Likewise, some operations
don’t have to happen right now.

For example, uploading
songs, recalculating storage, or resizing your photos
should probably not be done while the user is out
in the middle of their holiday shopping, right?

And network requests are
another big drain on battery.

See, each time you turn on
your phone’s mobile radio it has to keep itself awake
for a few seconds in case a response packet comes in.

Of course, needing to draw extra
battery just to stay awake.

So if you’re polling
an ad server every five seconds or so, you’re going
to be incurring the cost over and over and over again.

Thankfully Android has several
tools to help you track down and fix these battery issues.

Firstly, you can get by battery
data stats on the device by going to Settings,
and then Battery, and then choosing the
application you’re interested in.

You’ll notice that the data
reporting on this screen is mostly about how long
your device is awake, and its networking connectivity.

And to dig deeper you can use
the battery historian tool to get a graphical
view of how your app is using the battery over time.

And once you’ve found
your app’s issues, Android has several APIs
that can help you fix them.

For example, using
the jobscheduler API allows your application to
defer various types of work to a time when the
battery is better to be used, like
when it’s plugged in, or when it’s connected
to the Wi-Fi, or the next time it wakes
up the device intentionally.

So if you’re looking to
optimize your application to be lean on battery
check out the rest of the Android performance
patterns resources to get more info on
saving every last piece of this precious
resource for your users.

So as always, keep calm,
profile your code, and remember, perf matters.

Источник


По теме: ( из рубрики Новости )

Оставить отзыв

Ваш адрес email не будет опубликован. Обязательные поля помечены *

*
*

двадцать + пятнадцать =

Похожие записи

наверх