Android 4.2: A new flavor of Jelly Bean.
Android 4.2 takes the speed and simplicity of Jelly Bean to a different level – a
completely new camera experience that’s beyond smart, a new form of typing that helps
you power through your messages, and much more.
Android 4.2 (
JELLY_BEAN_MR1)
is an update to the Jelly Bean release that offers new features for users and app
developers. This document provides an introduction to the most notable and
useful new APIs for developers.
As an app developer, you should download the Android 4.2 system image and SDK platform from
the
SDK Manager as soon as possible. If you
don’t have a device running Android 4.2 on which to test your app, use the Android 4.2 system
image to test your app on the
Android emulator.
Then build your apps against the Android 4.2 platform to begin using the latest APIs.
Daydream
Daydream is a new interactive screensaver mode for Android devices. It activates automatically
when the device is inserted into a dock or when the device is left idle while plugged in to a
charger (instead of turning the screen off). Daydream displays one dream at a time, which may
be a purely visual, passive display that dismisses upon touch, or may be interactive and responsive
to the full suite of input events. Your dreams run in your app’s process and have full access to
the Android UI toolkit, including views, layouts, and animations, so they are more flexible and
powerful than either live wallpapers or app widgets.
Secondary Displays
Android now allows your app to display unique content on additional screens that are connected
to the user’s device over either a wired connection or Wi-Fi.
To create unique content for a secondary display, extend the
Presentation
class and implement the
onCreate() callback. Within
onCreate(), specify your UI for the secondary display
by calling
setContentView().
As an extension of the
Dialog class, the
Presentation class provides the region in which your app can display a unique UI on the
secondary display.
Lockscreen Widgets

4.2 Jelly Bean brings widgets to the lockscreen. Android phone makers
like Samsung and HTC have long been trying to fix the static lock screen
in stock Android, adding some shortcuts to it, but now Google finally
solves this problem. You can now sidescroll right to go into the camera
and left to look at widgets. Out of the box there are only four widgets
that you can add to the lockscreen, but third-party apps have already
started offering lockscreen widgets, so in addition to the stock Gmail
for example, you can have say a Twitter widget (via Plume for
instance). Good news is that all of those lockscreen widgets are
dynamically updated in the background. Whenever you receive a new email
you can check it out straight from the lockscreen widget and without
going into the mail app.
One word of caution though. Lockscreen
widgets do not require a password. Even if you have your device
password-protected, anyone can see the widgets without being asked for a
password. That means that if you have a Gmail lockscreen widget, anyone
who picks up your phone can read your emails on the widget (not in the
app, though). This is not a bug, this is a feature. It is there for your
convenience, so if you are concerned about the privacy of your email
the solution is simple - don’t use those lockscreen widgets that reveal
your information.
Multiple Users
Android now allows multiple user spaces on shareable devices such as tablets. Each user on a
device has his or her own set of accounts, apps, system settings, files, and any other
user-associated data.
As an app developer, there’s nothing different you need to do in order for your app to work
properly with multiple users on a single device. Regardless of how many users may exist on a
device, the data your app saves for a given user is kept separate from the data your app saves
for other users. The system keeps track of which user data belongs to the user process in which
your app is running and provides your app access to only that user’s data and does not allow
access to other users’ data.
Saving data in a multi-user environment
Whenever your app saves user preferences, creates a database, or writes a file to the user’s
internal or external storage space, that data is accessible only while running as that user.
Identifying users in a multi-user environment
If your app wants to identify unique users such as to gather analytics or create other account
associations, you should follow the recommended practices for
identifying
unique installations. By creating a new
UUID when your app starts for the
first time, you’re certain to obtain a unique ID for tracking each user, regardless of how many
users install your app on a single device. Alternatively, you can save a local token fetched from
your server or use the registrations ID provided by
Google Cloud Messaging.
Beware that if your app requests one of the hardware device identifiers (such as the WiFi MAC
address, the
SERIAL number, or the
ANDROID_ID number), they will provide the same value for each
user because these identifiers are tied to the hardware and not the user. Not to mention the other
problems these identifiers introduce as discussed in the
Identifying
App Installations blog post.
New Global Settings

Next on the list of updates is Quick Setting, a menu of the most oft
used toggles and shortcuts, designed to save the average user a trip to
Settings. You bring this by either scrolling down from the top to bottom
with two fingers, or bringing the notification shade and pressing the
Quick Button icon in the top right corner.
Those are welcome
additions - displaying things like the battery percentage, and allowing
to set the screen brightness, but we do feel that Google could have
easily gone with direct toggles for some of the things. Instead we get
shortcuts. One glaring example is brightness. Instead of a brightness
slider right into the menu, you have to first tap on a shortcut, and
only then you get to adjust the screen brightness. That might be picking
the nits, but we had to get it off our chests.