The CommonsBlog

The Busy Coder's Guide to Android Development Version 7.6 Released

Subscribers now have access to the latest release of The Busy Coder’s Guide to Android Development, known as Version 7.6, in all formats. Just log into your Warescription page and download away, or set up an account and subscribe!

This update represents a whole lot of “miscellaneous”, since I was uncertain of Google’s release schedule for a bunch of stuff (Android Studio 2.2, Android 7.0, and ConstraintLayout).

In this update, I:

  • Extracted the material on multi-window implementations into a separate chapter, one that includes information about supporting Samsung’s and LG’s proprietary multi-window approaches

  • Expanded the coverage of drag-and-drop to mention how it works with the Samsung/LG multi-window environments, Chrome OS, etc.

  • Added a new section to the chapter on Espresso, covering IdlingResource

  • Added a new section to the chapter on RecyclerView, covering having items that expand and contract

  • Added a new section to the chapter on the media projection APIs, covering andshooter, a screenshot utility app

  • Updated the chapter on consuming documents to cover the duration of access to content identified by Uri values

  • Added material on the problems with custom Parcelable implementations to the chapter on Parcelable

  • Added a short section on @InverseBindingAdapter to the chapter on the data binding framework

  • Added a section on supporting APPLICATION_PREFERENCES on Android N devices

  • Added a section on onRetainNonConfigurationInstance() to the chapter on configuration changes

  • Added a section on the OnAlarmListener APIs offered by AlarmManager on Android N

  • Added a section on writing a custom Loader implementation

  • Refreshed the chapter on audio playback, which was seriously old

  • Updated the Decktastic sample app and chapter, which also was out of date

Also, the APK edition of the book has new appinars on:

  • the 2016 updates to the data binding framework

  • printing

  • publishing content with a FileProvider or StreamProvider

  • consuming documents from the Storage Access Framework


The next book update is tentatively slated for early October. That may change based upon when Android Studio 2.2 hits the release channel.

Aug 22, 2016

The Magical OpenJDK Migration

Five months ago, I warned readers that Android N was switching to the OpenJDK for its java.* and javax.* class implementations. A couple of JDK-related bugs were quickly posted, and I was afraid that they might be the tip of the iceberg.

As it turns out, they were the tip of the ice cube.

I have not heard screams of anguish over the OpenJDK migration. In fact, I have not heard much of anything beyond the bugs pointed out in my original blog post (which have since been fixed). There are few SDK-related OpenJDK bugs on the issue tracker. There seem to have been few recurring “help! this stuff is broken!” questions on Stack Overflow. It’s been very, very quiet.

This is roughly akin to the trick where the magician yanks the tablecloth out from underneath a bunch of place settings. In this case, only a couple of salad forks wiggled.

(we knew that the butter knife would be stable, of course)

This is really quite impressive. Had you told me five months ago that things would go this smoothly, I doubt that I would have believed you. A largely bug-free migration would have seemed to be a really big “ask”, given any quirks in the original Apache Harmony implementation, with any Android quirks layered atop them.

I can only guess at the amount of work that must have gone into this. Worse, the work had only downside risk: in the best-case scenario, nobody sees a change. To the team that worked on this: many, many thanks for making this portion of Android N smooth!

Aug 19, 2016


Android N lets you link an activity of yours into your app’s page in Settings. Just add an <intent-filter>:

    <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
    <category android:name="android.intent.category.DEFAULT" />

Android N’s Settings app will look for the activity in your app that has that <intent-filter>. If Settings finds one, it will add a gear icon to your app’s page in Settings, and if the user taps the gear, they will be taken to your designated activity. The idea is that you would use this for your own application settings, so the user can navigate from Settings to your app’s settings, if desired.

At the risk of quoting a meme, this is nice.

However, most likely, your settings activity did not have an <intent-filter> prior to adding this one. By adding this <intent-filter>, you have made this activity be exported. Any app can start your activity whenever the app wants. Your activity needs to be exported, so that the Settings app can start the activity.

However, there is a substantial difference between “the Settings app can start the activity” and “any app can start the activity”. If your settings are fairly banal, there may be no issue. But if your settings includes things like account information, you might want to limit what apps can start it.

One way to constrain this is to add android:permission to the <activity>, indicating that only apps that hold a certain permission can start the activity. If we pick a good permission, Settings will hold it, but other apps will not. Unfortunately, there is no documentation for what permssion we should use.

WRITE_SECURE_SETTINGS seems like a likely candidate, though. Clearly, the Settings app will hold it. And, since only system apps can hold that permission, the run-of-the-mill apps that the user installs will not be able to start your activity.

That gives us:

    <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
    <category android:name="android.intent.category.DEFAULT" />

With luck, we will get official advice on this someday.

UPDATE 2016-08-18: cketti points out that you can use android:exported="false" to block other apps, yet Settings can still start the activity. Right now, I am not quite certain why this works, but it does.

Aug 17, 2016

Warescription Pricing: Now $20/Six Months

The Warescription program, providing access to the Busy Coder’s Guide to Android Development and other services, now costs $20 for a six-month subscription. The hope is that this will make it accessible to more developers than was the earlier $45/year pricing.

If you have any questions or concerns about this, please contact me.

Aug 15, 2016

Upcoming Presentations

I’ll be delivering a few presentations over the next eight weeks.

First up is the Android Summit (not to be confused with the Android Developer Summit that Google hosted last year). This will be August 26, in the Washington DC area. I’ll be talking about multi-window development on Android 7.0.

A few weeks after that (September 23-24), I’ll head back down to DC for DevFest DC, where I will talk about the sheer unbridled joy that one finds when implementing periodic work on Android.

(and, yes, I’m being sarcastic)

The following week (September 29-30), I’ll be in the Remarkably Large Apple for droidcon NYC. I will be talking about Android’s drag-and-drop framework and how it becomes more important with Android 7.0’s multi-window feature. However, I will not be wearing khakis.

I am happy to help out other events as well:

  • If you are running a conference in the Boston/Pittsburgh/DC area, let me know!

  • If you have a Meetup, GDG, or similar group in the NYC/Harrisburg/Philly area, I’d be happy to come visit!

  • If you run such a group, but it is outside of that area, and you are willing to have me present via a Web conference, just shout!

  • If you are running a conference, you really want a presentation on some topic, nobody submitted a talk for that topic, and you think that I can fill the gap, ask!

Aug 11, 2016

Older Posts