Random Musings on the N Developer Preview 3
Each time Google releases a new developer preview, I try to talk about the changes that Google isn’t talking about.
N Developer Preview 3 (NDP3) represents another incremental change over N Developer Previews 1 and 2. Google did not bother with an announcement blog post, AFAICT, though there are some release notes.
This post outlines some things that have caught my eye in NDP3.
Regressions and Changes… Compared to Production Android
postDelayed() methods, as does
On the whole, I have been steering developers to use the ones on
as you pretty much always have a widget available, so there is little
sense in creating a
Handler instance just for
postDelayed(). However, NDP3 makes a slight change here:
If an app posts
Runnabletasks to a
View, and the
Viewis not attached to a window, the system queues the
Runnabletask with the
Runnabletask does not execute until the
Viewis attached to a window.
For a lot of uses of
post(), this will not be a problem.
might get more interesting, particularly if you are using a “
postDelayed() invoking a
Runnable that calls
postDelayed() to schedule
itself again). That loop will only work so long as the
View you are using
is attached to a
Window. If you are concerned about this, beyond
testing your existing implementation, you might consider switching to
Handler instance for
- The week number feature on
CalendarViewis now deprecated
- The embedded
DatePickeris now deprecated and is “not supported by Material-style
Regresssions and Changes… Compared to NDP2
ShortcutsManager added in NDP2 still exists in NDP3, but the
release notes indicate that it will be retired in a future developer
preview. I would not recommend investing further time in it.
Other Stuff in NDP3
There are other curiosities tucked into the API differences report, above and beyond the items called out in the release notes:
There is now an
Intentaction, to “launch an activity showing the app information”. This appears to be tied to the Play Store and other app installation channels, suggesting that you can use this to display information about apps that are not yet installed.
If you create an
Intentdirectly (rather than via the
createChooser()helper method), you can add
EXTRA_EXCLUDE_COMPONENTSto list particular components that should be excluded from the list of choices. This is very handy for cases where you have your own activity that handles some implicit
Intent, but you specifically want to open some
Uriin any other activity handling that type of content. For example, perhaps you are having difficulty rendering the content, and you want to allow the user to try viewing that content in a third-party app.
There is a new
Notification, which is a “helper class for generating large-format notifications that include multiple back-and-forth messages of varying types between any number of people”. I have not tried this yet to determine whether it is something that might be specific to certain form factors (e.g., Wear) or whether it is available across the board.
Some options that we have on
JobScheduler, such as “only while charging”, and “only while idle”, are now available on
DownloadManagervia methods on
stopForeground()is being migrated from taking a
boolean(whether or not to remove the
Notification) to an
JobScheduler, to allow us to monitor a
ContentProviderfor changes without having an always-running service. NDP3 adds
setTriggerContentUpdateDelay(), to postpone running the job until the content has stabilized, so jobs do not run multiple times for a series of minor changes to the content.
setTriggerContextMaxDelay()sets a cap on that delay. Between those two, you can have a modicum of control over how frequently your content-related jobs are invoked.
android.view.PixelCopymethod allows you to asynchronously(?) copy the contents of a
Bitmap, with a callback when that work is completed.
Bugs in NDP3
Some of the bugs that I filed against NDP1 and NDP2 were fixed, particularly ones related to quick-settings tiles.
However, some bugs that I filed are still outstanding, such as:
- A bug related to the
- Another bug related to
- One of my
I also have not yet confirmed whether the
that I filed has been fixed… as I cannot get
work at all anymore. I am still investigating this.
Learn second-generation Android app development — with Kotlin and the Android Jetpack — through CommonsWare’s Android app development training!