Adding a “What’s New” screen to your Android application

In some case, you want users of your application to explicitly approve a License before being able to use your software. Adding an EULA (End User License Agreement) screen (a Dialog) to pop at the first start of an Android Java Application, is really simple and well documented on the web.

If you want to enforce the EULA at each new release of your application (which could become quickly annoying, beware!), give a look at this linked blog post a “SimpleEula” sample code showing how to do that simply. Something like this is needed as well if you want to update the term of the license.

But what I want is a simple “What’s New” screen to show at each new release, but without the EULA annoyance and without”cancel button”. The kind of dialog we are seeing  more and more nowadays in application of the market. From the above linked example, I’ve made a really simple “What’s New” dialog, here is the sample code:

public class WhatsNewScreen {
    private static final String LOG_TAG                 = "WhatsNewScreen";

    private static final String LAST_VERSION_CODE_KEY   = "last_version_code";

    private Activity            mActivity;

    // Constructor memorize the calling Activity ("context")
    public WhatsNewScreen(Activity context) {
        mActivity = context;

    // Show the dialog only if not already shown for this version of the application
    public void show() {
        try {
            // Get the versionCode of the Package, which must be different (incremented) in each release on the market in the AndroidManifest.xml
            final PackageInfo packageInfo = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);

            final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
            final long lastVersionCode = prefs.getLong(LAST_VERSION_CODE_KEY, 0);

            if (packageInfo.versionCode != lastVersionCode) {
                Log.i(LOG_TAG, "versionCode " + packageInfo.versionCode + "is different from the last known version " + lastVersionCode);

                final String title = mActivity.getString(R.string.app_name) + " v" + packageInfo.versionName;

                final String message = mActivity.getString(R.string.whatsnew);

                // Show the News since last version
                AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
                        .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {

                            public void onClick(DialogInterface dialogInterface, int i) {
                                // Mark this version as read
                                SharedPreferences.Editor editor = prefs.edit();
                                editor.putLong(LAST_VERSION_CODE_KEY, packageInfo.versionCode);
            } else {
                Log.i(LOG_TAG, "versionCode " + packageInfo.versionCode + "is already known");

        } catch (PackageManager.NameNotFoundException e) {


You have to call it on the onCreate of the first activity of your application:

    /** Called when the activity is first created. */
    protected void onCreate (Bundle savedInstanceState) {

        // Layout of the main activity

        // Show the "What's New" screen once for each new release of the application
        new WhatsNewScreen(this).show();


Here is an example of the XML string resource used res/values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>

    <string name="whatsnew">
        - Removed many SQLite exception stack\n
        - Improved the way the application launch on notification (no more multi-activity stacking)\n
        - Added this What\'s new screen\n



Android official ressources

The official Android Developer website really is THE perfect place for anything related to Java development for Android (*), and it is regularly updated !

You should start with the Android Basics in the Android Dev Guide, that will give you an initial overview of the platform.

Then, you can follow the Tutorials in the Developers Resources, after what you would be able to look at the Sample Code in the same place.

Personally, I also did a complete survey of the Developer Blog that is full of good idea. I am now following it through RSS feeds, but some of those good technical advice can also be found in the Technical Resources->Articles section, in the Common Tasks and in various FAQs.

Last but not least, if you like, you could also follow some of the Google I/O conferences and other related interviews on the Videos section.

I also love to look twice a month at the charts of Android Versions showing how new platform API are spreading, which can help you choose the API level you want to be compatible with (edit: chart updated in April 2011) :

Android Versions ChartSince the beginning (December 2009), I’ve decided to stick to Android >=2.0 (API level 5) and now Android 2.1+ represents more than 80% of the active devices (edit: now more than 90% at the time of the chart upload).