Table of Contents
Random Musings on the Android 13 Developer Preview 2
Each time Google releases a new developer preview, I rummage through
the API differences report
the high-level overviews,
and even the release blog post,
to see if there are things that warrant more attention from
developers. I try to emphasize mainstream features that any developer
might reasonably use, along with things that may not
get quite as much attention, because they are buried in the JavaDocs.
What Got Clarified From Last Time
About five weeks ago, I wrote about DP1.
This time around, the “13 DP1 while 12L is in beta?” answer is “12L is now folded
into DP2”.
Also, they are now
documenting the POST_NOTIFICATIONS
permission.
Of particular note is that this permission affects all apps, regardless of
targetSdkVersion
. If your targetSdkVersion
is below Android 13’s presumed
value of 33
, the system will prompt the user to grant permission when you create
your first notification channel, for a newly-installed app on 13.
If you create that channel at an inopportune time… you will
need to modify your app.
They are also documenting the new option for controlling whether a dynamically-registered receiver is exported.
And, they mentioned in the blog post the option for revoking already-granted
permissions, though the method name changed.
Plus, they talk a bit about BODY_SENSORS_BACKGROUND
.
But beyond that, the mysteries from DP1 remain mysteries.
What Else Got Announced Of Note?
The biggest thing is the Foreground Services (FGS) Task Manager. This allows
users to stop your app’s process easily from the notification shade, if your
app has a foreground service running. Of particular note is that the OS will
nag users periodically about your app, if your service runs most of the time
(20 hours out of the preceding 24, with a maximum of one nag per month).
Developers may wind up adding flags
to avoid users getting bothered by those messages, which in turn will cause
Google to remove the impacts of those flags in some future Android release.
(if you spend enough time in Android development, predicting developer-and-Google
actions in advance becomes simply a matter of pattern matching…)
The War on Background Processing
continues, beyond the FGS Task Manager.
In a tweak to JobScheduler
, “In Android 13, the system now tries to determine the next time an app will be launched”,
which is not at all creepy. Nope, not one bit.
The official blog post mentions a few things that might impact a small
percentage of developers.
And, that’s pretty much it for official stuff.
What’s Up With All the New Permissions?
DP2 adds 15 new permissions over DP1,
let alone prior versions of Android.
Some of these, like MANAGE_WIFI_AUTO_JOIN
and MANAEG_WIFI_INTERFACES
, are
documented as “Not for use by third-party applications”, which makes you wonder
why they bothered to put them in an Android SDK that is explicitly for third-party applications.
They have added three content-specific permissions: READ_MEDIA_AUDIO
,
READ_MEDIA_IMAGE
, and READ_MEDIA_VIDEO
. The JavaDocs indicate that these
are replacements for READ_EXTERNAL_STORAGE
, but only for those app that target
Android 13 or higher. Presumably, holding one of these permissions, and not READ_EXTERNAL_STORAGE
,
only gives you read access to that media type and not other content.
The other permission that may generate widespread interest is USE_EXACT_ALARM
.
Android 12 added SCHEDULE_EXACT_ALARM
to be able to use exact alarms, but this
is an “app ops” permission, one that users have to grant directly in Settings.
USE_EXACT_ALARM
appears to be a normal
permission, but the JavaDocs make it
plain that the Play Store (and perhaps elsewhere) will require you to fill out a form
to be able to ship an app that requests it. As many developers are discovering
with MANAGE_EXTERNAL_STORAGE
, you need a really good reason to request one of these
sorts of permissions.
What Is Up In the Clouds
Last time, I mentioned ACTION_PICK_IMAGES
and how it may be backed by CloudMediaProvider
objects.
It appears that this might extend beyond images someday, as there are
new interfaces tied to CloudMediaProvider
rendering previews on a supplied Surface
It’s possible that this is just for animated images, but my guess is that there
may be more coming in this area, if not in Android 13 then in future versions
of Android.
What Makes Me Want to Change the Channel
There are a ton of new and changed classes
in android.media.tv
,
which pertains to actual TV channel playback on an Android TV device.
And, there are
changes to the new android.media.tv.interactive
package,
including a new TvInteractiveAppService
.
That is described as “a service that provides runtime environment and runs TV interactive applications”.
It is not completely clear what “TV interactive applications” are that are somehow
different from “applications that run on Android TV”.
What Brings to Mind a Beatles Song
Activities, fragments, and dialogs all now implement OnBackInvokedDispatcherOwner
.
From these, you can get an OnBackInvokedDispatcher
and use that to register an OnBackInvokedCallback
,
allowing you to get back.
What Makes Me Wonder If These Supplements Are FDA-Approved
A process can be supplemental.
It is unclear what this means.
There is also a new supplementalapi
package,
containing an AdServicesVersion
. Because of course an operating system
should be in the business of managing ads.
Oddly, given these changes, SUPPLEMENTAL_PROCESS_SERVICE
was removed in DP2 after
having been added in DP1.
What Fulfills Some Developer Fantasies
I see a fair number of developers wanting to block or the screenshots shown in the overview
screen. FLAG_SECURE
blocks them nicely, but also blocks all other types of screenshots.
Some developers have been trying to play games with replacing the activity content
at just the right time, like that’s ever going to be reliable. Now, we finally can
opt out of those screenshots.
What Helps Me Stay Awake At Night
You can now call setStateListener()
on a WakeLock
and register a WakeLockStateListener
,
letting you know if the WakeLock
is enabled or disabled.
Mostly, this appears to be for cases where you want the wakelock to be enabled,
but the system decided to disable it.
What Else Caught My Eye
There are a bunch of new feature identifiers,
including ones that seem tied to the 12L merger (e.g., FEATURE_EXPANDED_PICTURE_IN_PICTURE
).
Android 12L added activity embedding, as one way to take advantage of larger
screen sizes. 13 DP2 appears to let you control which apps can embed your
activities, via android:knownActivityEmbeddingCerts
attributes on <application>
and <activity>
. And, it appears that you can
allow arbitrary apps to embed your activity via android:allowUntrustedActivityEmbedding
.
There is now an EthernetNetworkSpecifier
,
suggesting a continued push into less-mobile devices, like perhaps TVs.
There is now a Dumpable
and DumpableContainer
pair of interfaces,
for dumping stuff to a PrintWriter
.
showNext()
and showPrevious()
on RemoteViews
are now deprecated
in favor of setDisplayedChild()
.
There is a new LocaleConfig
class,
with a broken explanation.
There is a new isLowPowerStandbyEnabled()
method on PowerManager
, continuing the War on Background Processing. Because
when you have 18 power modes, adding a 19th will help. On the other end of the
power spectrum, you can now find out if you are plugged into a dock,
though I now really want BATTERY_PLUGGED_WHARF
and BATTERY_PLUGGED_PIER
as well.
And it still seems as though changes are afoot for android:sharedUserId
, as
the new EXTRA_NEW_UID
will tell you about changes to uids.
More Stories
How to Buy Your Next Pair of Glasses Online
Google Pixel Buds Vs Apple AirPods – The Battle of the Earbuds
Replace albums with keywords in iCloud Shared Photos – Six Colors