Random Musings on the R Developer Preview 4

Each time Google releases a new developer preview, I read what I can to see if there are things that warrant more attention from developers. That even includes musings about developer previews that we were not expecting, such as today’s Developer Preview 4 (DP4).

The deeper we get into the preview/beta series, the fewer changes we see. That is particularly true for this release, squeezed in between between the DP3 of about 2 weeks ago and the Beta 1 due out in a month.

On the whole, it feels like Google elected to back off on some changes, perhaps ones that were unlikely to be stabilized sufficiently by some internal deadline. So, the API differences report from DP3 to DP4 shows a bunch of removals of stuff added in previous previews. What will be interesting is whether this leads to an 11.1 release in late fall — we have not had a point release in three years, but it might be that Google elects to have some features slide. I do not expect an 11.1, but the odds seem higher this year than they were last year, just because of the problems induced by SARS-CoV-2 and COVID-19.

However, a few things caught my eye.

What Might Break Your App?

The big one is the change to phone number access. If you have been using methods like getLine1Number(), you now need a different permission:

Starting in Developer Preview 4, apps that want to access phone numbers through the TelephonyManager.getLine1Number() and TelecomManager.getLine1Number() methods must request the READ_PHONE_NUMBERS permission.

READ_PHONE_NUMBERS is a dangerous permission, meaning that not only will you need a manifest change, but you will need to tweak your runtime permission requests as well.

There is a new LimitExceededException, with no clear picture of what limit we might be exceeding. It will be interesting to see if anyone encounters this and in what circumstances.

If you have been using alternative build tools and are compressing your resources.arsc file, that will not be supported once your targetSdkVersion reaches R or higher.

What Else Changed?

If you have been playing with bubbles, there are a few changes in Notification.BubbleMetadata.Builder.

The special info for waterfall displays and foldables is nice, for the handful of apps that are going to try to do special things for those form factors.

In Android R, the Storage Access Framework has restrictions on what the user can select (e.g., ACTION_OPEN_DOCUMENT_TREE will not let the user select a storage root directory). However, in R DP4, that restriction is now only taking effect with a targetSdkVersion of R or higher.

SQLiteDatabase got a new execPerConnectionSQL() method. You supply some SQL, and that SQL will get executed whenever a database connection gets established. This is useful for PRAGMA statements that configure your use of the database.

And, as Android Police reported, the gesture to undo swiping an app off the overview screen appears to have been removed. It is unclear whether it might make a return later in the R development process or if it has been shelved for a longer period of time.

What’s Next?

The next milestone is Beta 1 on June 3. This comes complete with its own beta launch show, to fill some of the gaps created by the loss of Google I|O.

I have some experiments to run, not only related to DP4 but also due to some undocumented changes in scoped storage. My guess is that the next update to Elements of Android R will come after Beta 1, sometime in mid-June.

Learn second-generation Android app development — with Kotlin and the Android Jetpack — through CommonsWare’s Android app development training!