Hi.
My name is Reto Meier.
I'm the tech lead for the Android Developer Relations
team at Google.
And I'm here to dig beneath the delicious chocolate
shell of the latest flavor of Android,
and into the wafer-biscuity goodness
at the center of the new developer features.
KitKat may only represent a 0.1 increase in version number,
but it turns out that a small bump can still
include a lot of new features.
Where the defining characteristic of Jelly Bean
was buttery smoothness, KitKat is
all about memory optimization.
Android 4.4 is designed to run just as smoothly
on a much broader range of devices, including those
with as little as 512 megs of RAM.
For developers, that means a selection of new APIs and tools
to help us ensure that our apps are
as memory efficient as the platform.
You can start by checking if your app is running on a memory
constrained device using the new .isLowRamDevice call
on the ActivityManager.
Based on the result, you might choose
to modify or even disable features
with significant memory implications
to ensure your app provides a great user
experience on devices with memory limits
similar to those featured by Guy Pearce's character
in "Memento."
Of course, disabling features is always a last resort,
so check out this guide for tips on how you can optimize
your app's memory usage without having
to sacrifice functionality.
But before you can start improving your app's memory
efficiency, you need to first understand
how you're using memory in the first place.
The new procstats tool helps you analyze memory resources,
providing data about app's execution durations and memory
use.
You can access procstats from the adb tool by calling,
adb shell dumpsys procstats.
If command lines make you nervous, fear not.
Android 4.4 also includes a new developer option
that helps you analyze your app's memory
profile on any Android 4.4 device
or emulator through the Process Stats developer option screen.
Below the system memory summary, there's
a list of blue bars indicating the relative computed memory
load of each app's process, and the relative percentage
of time each has spent in the background.
Selecting that displays a summary of the memory consumed
and the percentage of the collection interval
that this particular app has been running for,
as well as the average and maximum RAM usage.
It's not all about memory efficiency, though.
KitKat also includes some new ways to build beautiful apps,
starting with some updates to the Android Design Guide,
designed to help you create striking,
innovative, and distinctive apps that
offer users a magical experience.
For more details, check out tomorrow's episode
of "Android Design in Action."
In terms of APIs, there's support
for a more immersive full-screen experience, a new transition
framework for animating scenes, closed captioning support,
and a new tool for high-fidelity screen recording.
The new full-screen immersive mode
lets you create full-bleed UIs that reach from edge to edge,
hiding all system UI, including the status and navigation bars.
It allows your app to respond to touch events
from areas that would otherwise be occupied by the system bars.
It's a great solution for rich, visual content such as photos,
videos, maps, books, and games.
You can enable this new mode using
two new mutually exclusive system UI
flags-- immersive and immersive_sticky.
This code shows how to toggle between
an immersive full-screen experience within your app
using the Immersive flag.
Alternatively, you can utilize the immersive_sticky flag
to create a persistent, immersive experience
that will automatically rehide the system
bars after a short delay, or if the user interacts
with the middle of the screen.
You can learn more about the new immersive
modes, including the best practices
for using each alternative, in Roman Nurik's Immersive Mode
DevByte.
To make it easier to create high-quality animations
in your app, Android 4.4 also introduces a new transitions
framework for animating between scenes.
Now it's pretty common to use animations
to help users understand their progress through UI states
where each state can expose different actions.
The new transitions framework helps you define these scenes--
typically view hierarchies like these-- and the transitions
which define how to animate the transformations between scenes
when the user enters or exits them.
You can use one of several pre-defined transition types
based on specific properties like layout
bounds or visibility, or use the auto-transition type
to automagically fade, move, and resize views
during a scene change.
You can also define custom transitions
that animate the properties that matter most to your app,
or even plug in your own animation styles.
For more details, check out the Transitions DevByte
by our master of animation, Chet Haase.
In an effort to make your apps more accessible,
Android 4.4 includes system-wide preferences
for closed captioning.
Users can now set global captioning preferences,
and apps that use video can use those settings to adjust
how they present closed captions by using the new Captioning
Manager.
Apps that use VideoView can simply
pass a captioning stream in WebVTT format,
along with the video stream for rendering.
And the system will handle display of the captions
according to those user preferences.
For more details, check out this DevByte by Alan Viverette,
the engineer who implemented it all.
If you've ever tried to record a demo of your app
by holding a video camera very steady,
you'll appreciate the new screen recording
tool that lets you capture video as you use the device
and store it as an MP4.
You can record in any device-supported resolution
and bit rate, and the output retains
the aspect ratio of the display.
You can access screen recording through the adb tool calling
adb shell screenrecord, or through the DDMS
panel in Eclipse or Android Studio.
KitKat also includes a couple of significant new storage API
changes, with a new storage access framework
and a fully supported SMS content provider.
The new storage access framework makes
it easier for users to browse and open documents, images,
and other files across all of the available local and
cloud-based document storage providers.
If you develop an app that manages files or uses
documents, you can integrate with the storage access
framework using the create_document
or open_document intents, and the system
will display the standard UI, including
content from all the available document providers.
If you want to add a storage provider,
you implement a new documents provider.
Overriding these four methods will
let you manage the browsing, reading, and writing
of any local or remote data that can be represented as files.
Then, you just need to add the documents provider
manifest intent filter, and request permission
to manage documents.
This process will register your provider with the storage
access framework and make it available to the standard UI.
Then, whenever your app is installed,
any app that uses this framework to view or select files
will provide access to your content.
Our very own Lisa Wray has created
DevBytes for both provider and consumer uses of the storage
access framework, so check them out for more details.
Now, if you've been using undocumented methods
to provide an SMS-based app, now is an excellent opportunity
to familiarize yourself with the official APIs for SMS handling.
That primarily involves a newly documented SMS content
provider, but also introduces new semantics
for receiving messages and writing to the provider.
When a message is received, the system
routes it directly to the user's default messaging app
using the SMS_DELIVER intent, while other apps
can continue to listen for incoming messages using the SMS
Received intent.
Only the default app is able to write new messages to the SMS
provider, but other apps can continue to read from it.
Apps that aren't the current default
can also continue to send messages.
Here, the system will write those outgoing messages
to the provider on your behalf, so that users can still
see them in their default app.
For more details, check out Adam's DevByte.
Also included in Android 4.4 are a number
of additions to help your app interact with the real world,
including new Bluetooth profiles for Bluetooth HID Over GATT,
which provides apps with a low latency
link for low-power peripheral devices like mice, joysticks,
and keyboards, and Bluetooth MAP for nearby device message
exchange.
There's also new platform support for built-in IR
blasters with a new API that lets
you check whether the device has an infrared emitter,
query its carrier frequencies, and then send infrared signals.
There's also support for host card emulation.
HCE adds support for secure NFC-based transactions
for things like payments, loyalty programs, card access,
and transit passes by allowing your app
to emulate an NFC smart card, though
without requiring a provisioned secure element.
It also supports a new reader mode
to have your app act as a reader for HCE
cards and other NFC-based transactions.
Android HCE emulates ISO 7816-based smart cards
using the ISO 14443-4 protocol for transmission,
along with the application identifiers as defined
in ISO 7816-4 as the basis for routing transactions
to the correct Android applications.
There's also native platform support for printing,
along with APIs for managing printing
over Wi-Fi or cloud-hosted services
such as Google Cloud Print.
You can use these new APIs to add printing capabilities
for nearly any type of content, from local images and documents
to network data or anything that you can render to a canvas.
Android uses PDF as its primary file format for printing,
so it's best practice to use the helper classes to print bitmaps
or to generate a properly paginated PDF
version of your content.
For convenience, the printing API
provides native and WebView helpers
to let you create PDFs using standard Android drawing APIs.
If your app knows how to draw the content,
it can create a PDF for printing it.
Nazmul Idris summarizes the best practices
for getting started with printing on Android
in this DevByte.
KitKat also introduces new ways to improve the power use
profile of device sensors, starting
with sensor batching, a new optimization
that delivers sensor results in batches
rather than as they are detected.
This lets the application processors
stay in a low-power state until each batch is delivered.
You can define the interval at which you receive batches
or request immediate delivery of events between batch cycles.
There's also two new composite sensors-- step detection
and step counting-- both of which
were implemented within hardware to help minimize the associated
power consumption.
And that's just a small taste of the new APIs available.
There's also a completely new implementation
of WebView based on Google Chromium that
offers the latest in standard support performance
and compatibility, and most of the HTML5
features available in Chrome for Android version 30,
plus an updated JavaScript V8 engine.
There's also a range of new APIs to better support RTL locales,
including drawable, mirroring, and pseudo-locales.
Declaring a drawable as auto-mirrorable
will allow the system to flip it automatically
for users using an RTL locale, preventing you
from having to duplicate your assets.
Android now also includes an RTL pseudo-locale
as a new developer option.
The pseudo-locale switches the device
to an RTL for all locales and displays text
in the current language.
This can help you find layout issues across your app
without having to display the app in an RTL language
that you may not be able to read.
There's also good news for fans of high performance computation
with performance improvements to render
script and the new ability to take advantage of render script
directly from your native code.
A new C++ API in the ADK lets you access the same render
script functionality available through the framework APIs,
including script intrinsics and custom kernels.
Last, but by no means least, is a series
of security enhancements, including
an update to Android's SELinux configuration, changing
from permissive to enforcing, and improved
cryptographic algorithms.
Elliptic Curve Digital Signature Algorithm support
has been added to the keystore provider.
And the script key derivation function
is now implemented to protect the cryptographic keys used
for full disk encryption.
In entirely related news, there is a new device
in town with the launch of the Nexus 5.
Check out Google Play for all the details
and grab one for yourself, purely
for development purposes, of course.
The Android 4.4 SDK is now available for your downloading
and code updating pleasure using the SDK manager.
And you can get more details on all of the new APIs, features,
best practice, and every other change
at developers.google.com.