Engage your Android users with new content after app upgrade

Evgeni Shafran
AndroidPub
Published in
3 min readNov 7, 2017

--

Recently I have been working on a silly app with a friend of mine. We created a fun to play nickname generator for Android called: The Nicknamer that includes 3 categories to choose from.

As with other projects I am working on, we choose the MVP (minimum viable product) way. Meaning our first version was quit simple and it didn’t contained all the features and categories we thought of, but with the intention we will keep updating it in following month and monitor its progress.

In the last update we added some new way to share content and a new shiny category: ‘Game of Thrones’.

The problem:

If we just roll out the version with the new category our new users will see it (hooray) but what about the users that already downloaded the app? (and didn’t uninstalled it yet). They will probably get the auto update from the play store and won’t know they have new content in it.

So how are we going to let out updated users know they have new awesome content to play with?

MY_PACKAGE_REPLACED Intent for the rescue:

Apparently Android already has a solution for us. You can register to: MY_PACKAGE_REPLACED intent in your manifest and it will fire when your app is updated. Once we get this intent we will show a notification that will let the user know that there is more content in the app.

MY_PACKAGE_REPLACED will be called only for your specific app so you wont get other app updates in that receiver. And because it’s not an implicit broadcast (fires only regarding your own app) it will keep working on Android Oreo too.

How to:

Add this to your manifest:

<receiver android:name=".UpdateReceiver" >
<intent-filter >
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>

Create UpdateReceiver class (The code here is Kotlin but it’s as simple as that in Java too):

class UpdateReceiver : BroadcastReceiver() {

val TAG = "UpdateReceiver"

override fun onReceive(context: Context, intent: Intent?) {
Log.d(TAG, "App got updated!")

val settingsData = SettingsData(context)

if (settingsData.
isShouldShowNewGameOfThronesCategoryNotification()) {
settingsData.
setShouldShowNewGameOfThronesCategoryNotification(false)
AppNotificationManager().createNewCategoryNotification(context)
}
}

}

In the code above we are also saving that we showed the notification so if the user will update to a newer version he will not get that notification again. (we also calling setShouldShowNewGameOfThronesCategoryNotification(false) in case the initial version have this category in our Application class)

  • It might not work if you have ‘Instant run’ enabled (otherwise the intent should fire up on every run from Android Studio).
  • Make sure to test the real use case. (An actual update from your previous version to the new one)

Personal note:

I feel that when we show our users a ‘new content available’ notification, pressing it should trigger some action related to its content.

In our case, we decided that once a user press it we will open the app with the nickname generator running with the new category, so our user will instantly get a taste of the new content.

--

--