Professional Documents
Culture Documents
What's New in Android 4.4 - Devoxx Belgium 2013
What's New in Android 4.4 - Devoxx Belgium 2013
What's New in Android 4.4 - Devoxx Belgium 2013
&
Chet Haase
Romain Guy
A few weeks ago, Google announced the release of Android 4.4 KitKat.
Whats New
Today were going to talk about whats new in Android. We wont be able to cover
everything but wed like to highlight some of the most exciting new features for
developers and users alike.
Today were going to talk about whats new in Android. We wont be able to cover
everything but wed like to highlight some of the most exciting new features for
developers and users alike.
The first device to run with Android 4.4 KitKat is the newly released Google Nexus 5.
Its not the focus of our talk but here is some info about the specs: 1080p display, 2 GB of RAM,
4-core 2.3 Ghz Snapdragon 800, Adreno 330 GPU, optical image stabilization
1,000,000,000
devices activated
Device activations
Here is a brief recap of the total number of activated Android devices since mid-2011.
Device activations
1,000
750
500
400
190
250
300
100
May 11
Oct 11
Jan 12
Feb 12
Jun 12
Sep 12
Mar 13
Here is a brief recap of the total number of activated Android devices since mid-2011.
Sep 13
JellyBean is now on >50% of Android devices and ICS 20%. Honeycomb barely registers at 0.1%.
Froyo < 2%
JB 52%
GB 26%
HC
ICS 20%
JellyBean is now on >50% of Android devices and ICS 20%. Honeycomb barely registers at 0.1%.
API 15-18
72%
API 8-13
28%
Documents
Storage Access
Framework
The new storage API makes it easy for users to browse and open local & cloud-based documents.
An advanced setting even allows to browse the entire file system.
You can display the standard UI by using the OPEN_DOCUMENT or CREATE_DOCUMENT intents.
The standard UI will show content from all registered document providers.
<provider
android:name="com.example.mycloud.MyCloudProvider"
android:authorities="com.example.mycloud.provider"
android:grantUriPermissions="true"
android:exported="true"
android:permission="android.permission.MANAGE_DOCUMENTS">
<intent-filter>
<action android:name=
"android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
You need to register your document provider by using the DOCUMENTS_PROVIDER intent filter
and requesting the MANAGE_DOCUMENTS permission.
Printing
New printing APIs can be used to add printing capabilities to almost any kind of content.
In particular, you can print anything you can render to a Canvas.
PrintHelper bitmapPrinter =
new PrintHelper(getActivity());
bitmapPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
Bitmap bitmap = BitmapFactory.decodeResource(
getResources(), R.drawable.my_bitmap);
bitmapPrinter.printBitmap("Untitled Image", bitmap);
The PDF API is powerful but if you want to print properly paginated bitmaps, it is
recommended you use helper classes.
User interface
Translucent system UI
Android 4.4 allows applications to draw behind the status bar and the navigation bar.
Theme.Holo.NoActionBar.TranslucentDecor
Theme.Holo.Light.NoActionBar.TranslucentDecor
There are two new themes you can use to request the new translucent system UI.
<LinearLayout
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
</LinearLayout>
If you request translucent sys bars, make sure to use fitsSystemWindows for the portion
of your layout that should not be covered by the system UI.
Immersive mode
We have a new immersive full-screen mode that hides the system UI even while the user interacts
with the application. This was previously only possible for passive content such as videos. This is
a great new API for content-rich applications that many of you have been asking for. To bring back
the system UI, swipe from the top or bottom edges.
To show the UI again, no new flag is necessary. These two methods can be used to
toggle the system UI dynamically.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
Alternatively you can create a persistent immersive experience that will automatically
re-hide the system UI after a short delay or if the user interacts with the middle of the
screen.
New WebView
Android 4.4 introduces a completely new backend for WebView, based on the
Chromium Open Source project that powers Chrome. This new WebView improved
HTML 5 support, remote debugging, etc.
Android 4.4 introduces a completely new backend for WebView, based on the
Chromium Open Source project that powers Chrome. This new WebView improved
HTML 5 support, remote debugging, etc.
Remote debugging is one of the best new features of the new WebView.
First, you must enable debugging on the WebView instance you want to inspect.
Connect your device over USB to a computer running Chrome and visit
chrome://inspect to start debugging your WebView.
chrome://inspect
Connect your device over USB to a computer running Chrome and visit
chrome://inspect to start debugging your WebView.
Connect your device over USB to a computer running Chrome and visit
chrome://inspect to start debugging your WebView.
// 1. From scratch
Scene(ViewGroup);
Scene.setEnterAction(Runnable);
Scenes
Scenes
Scenes
// 1. Individual transitions
new ChangeBounds();
new Fade();
Transitions
// 2. Transition groups
TransitionSet set = new TransitionSet();
set.addTransition(new ChangeBounds())
.addTransition(new Fade());
Transitions
// 3. From XML
<transitionSet>
<changeBounds/>
<fade/>
</transitionSet>
Transitions
void captureStartValues(TransitionValues);
void captureEndValues(TransitionValues);
Animator createAnimator(ViewGroup,
TransitionValues, TransitionValues);
Custom transitions
TransitionManager
TransitionManager
TransitionManager
TransitionManager.beginDelayedTransition(ViewGroup);
Closed captioning are now controlled by system-wide settings, found under Accessibility.
Apps can access and adjust these settings using the new CaptioningManager.
When you use a VideoView you can now simply pass the captions in WebVTT format.
VideoView will take care of rendering the captions according to the users preferences.
The captioning manager lets you listen to preferences changes and access the style
chosen by the user, including the typeface, background color, etc.
Drawables auto-mirroring
In RTL mode drawables sometimes have to be mirrored (arrows for instance.) Until now
it required the app to embed two versions of each asset, one going in the drawable-rtl/
resource directory. Mirroring is now handled automatically.
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/spinner_ab_default_holo_light_am"
android:autoMirrored="true">
</nine-patch>
Drawable d = resources.getDrawable(R.drawable.spinner);
d.setAutoMirrored(true);
You can also of course set the auto-mirror property from code.
Supporting RTL locales is important to reach out as many users as possible but it can be
difficult to test your application and use the system in Arabic or Hebrew.
A new developer option lets you force RTL mode with your favorite locale to test your apps.
Performance
Re-usable bitmaps
There is now a distinction between a bitmaps backing store and its configuration. You can
for instance allocate a bitmap thats larger than what you need. As long as it can hold enough
data, you can reconfigure it however you please by changing the width, height and configuration.
This is of course particularly useful when decoding bitmaps from external resources.
You can pre-allocate bitmaps large enough to hold your incoming data and never allocate
new bitmaps.
Shared
assets texture
Android 4.4 now generates a single texture containing all the framework assets, shared by
all processes. This saves a bit of memory in every process but it also helps batching and
merging drawing operations to optimize applications automatically.
Software v-sync
SurfaceFlinger in OpenGL ES 2.0
Asynchronous texture uploads
Other notable graphics improvements. Software v-sync triggers redraws a little ahead of
the hardware v-sync to reduce latency. Async texture uploads improve apps that uses
a large number of glyphs (CJK, emojis, etc)
RenderScript
RenderScript is now part of the NDK.
There is also a support library.
performTraversals
draw
getDL
drawDisplayList
flush drawing commands
systrace
systrace got even more useful in Android 4.4, with new tags (animations, inflation, etc.)
and the ability to use it from monitor (DDMS). Lets look at a demo, using Launcher.
Android 4.4 introduces a new overdraw debugging tool that shows you the amount of
overdraw per window.
Project Svelte
Project Svelte was an effort in Android 4.4 to reduce memory usage across the board
(system & apps) to ensure KitKat can run well on devices with 512 MB of physical RAM.
Procstats
ActivityManager activityManager =
(ActivityManager) getSystemService(ACTIVITY_SERVICE);
if (activityManager.isLowRamDevice()) {
// Modify memory use behavior
}
Connectivity &
media
Adaptive playback
Support for adaptive video playback is now available with the MediaCodec APIs, enabling seamless change in
resolution during playback onto a Surface. You can feed the decoder input frames of a new resolution and the
resolution of the output buffers change without a significant gap.
Loudness enhancer
The LoudnessEnhancer is a new subclass of AudioEffect that allows you to increase the audible volume of your
MediaPlayer or AudioTrack. This can be especially useful in conjunction to increase the volume of spoken audio
tracks while other media is currently playing.
The new ImageReader API provides you direct access to image buffers as they are rendered
into a Surface. The Image object provides direct access to the image's timestamp, format,
dimensions, and pixel data.
Android 4.4 adds a long awaited feature: screen recording. The screenrecord command
can record a video of your device for a duration of up to 3 minutes.
You can also invoke the screen recording command from Android Studio.
The record button can be found in the Android DDMS panel (Alt-6).
You can also invoke the screen recording command from Android Studio.
The record button can be found in the Android DDMS panel (Alt-6).
And more!
Android 4.4 supports new language features such as the diamond operator.
The compiler can infer the type of the right-hand side expression for us.
This feature is retro-compatible.
It is not possible to use String types in switch statements. This makes the code a lot
more readable than a series of if (mystring.equals(astring)).
This feature is retro-compatible.
Automatic resource management will take care of calling close() for you.
No more try/catch for IOException around close() calls in your finally statement!
Auto resource management works on classes that implement AutoCloseable,
present in API level 19 only.
try {
readFile();
} catch (FileNotFoundException | IOException e) {
// Do something useful
If several exceptions are thrown in a block of code and needs to be handled the
same way, you can now catch them all with a single catch without catching
a base class.
This feature is retro-compatible.
New runtime
Android 4.4 offers the option to switch to a new runtime, called ART, for development
purposes only. ART is included so you can test your application but Dalvik should remain
the default runtime for normal use.
To enable ART, go to Developer options, and click the Select runtime entry.
After selecting ART you will need to reboot the device.
developer.android.com/about/versions/kitkat.html
developer.android.com/about/versions/android-4.4.html
More info
More info
Chet Haase
google.com/+ChetHaase
Romain Guy
google.com/+RomainGuy