Android: A Simple Eula for your Android Apps

There comes a time when you need to show a EULA to your users of your Android apps. Doing this is pretty easy if you decide to ALWAYS show it when the user uses your app. However, that’s beyond annoying. The best case scenario for displaying a EULA to a user would go like this…

  • User installs your app
  • User opens your app
  • User is presented with a EULA
  • Users Accepts EULA?
    • No –> Close app
    • Yes –> Continue
  • User uses app, closes it.
  • User re-opens app for a subsequent use. EULA IS NOT displayed.
  • An update for the app is available.
  • User installs App Update
  • User opens the app.
  • User is presented with a new updated EULA again.

As you can see, this can become a royal PITA for managing. So how do you do you it?

Very simple. Use the version code and the shared preferences.

How To Implement the File

I’ve created a file by the name of that will display a Dialog with the Eula and two buttons (Ok, Cancel … You can rename them anything you want). Upon initialization of the first activity of the app, SimpleEula will grab the version code of the app, and then use that version code to create a unique key for the version. Such as “eula_1″ or “eula_2″, etc. SimpleEula uses this key to check shared preferences if this key has been set. If it HAS then it means that the user has accepted the EULA and nothing happens, the user is greeted with the first activity of the app. If the key has NOT been seen before, SimpleEula will display a Dialog with a Eula in it (along with app updates – which both from from the string resources of the app)  and the user can accept or decline the Eula (Ok or Cancel buttons). If the user selects OK, the key is set in shared preferences so upon susequent app starts, the Eula WILL not be displayed.

Therefore, the only time the user will see a new Eula display to them is when the version code changes. Since new features are introduced in new versions, this is the perfect time to show the Eula again.

Whats the code look like?

To use SimpleEula, add the file (download below from the sample project on GitHub) to your app. Add the required string resources:

  • eula
  • updates

Then in the first activity of your app, add a call to SimpleEula’s show method:

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        new SimpleEula(this).show();

This will create Eula that looks like this:

The user clicks “OK” and the eula key will be saved in shared preferences and the user will not be bugged about the Eula again until an app update is made.

Here’s the full code for You can also download the sample project on GitHub via the link at the end of this post.

public class SimpleEula {

	private String EULA_PREFIX = "eula_";
	private Activity mActivity;

	public SimpleEula(Activity context) {
		mActivity = context;

	private PackageInfo getPackageInfo() {
        PackageInfo pi = null;
        try {
             pi = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
        return pi;

     public void show() {
        PackageInfo versionInfo = getPackageInfo();

        // the eulaKey changes every time you increment the version number in the AndroidManifest.xml
		final String eulaKey = EULA_PREFIX + versionInfo.versionCode;
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
        boolean hasBeenShown = prefs.getBoolean(eulaKey, false);
        if(hasBeenShown == false){

        	// Show the Eula
            String title = mActivity.getString(R.string.app_name) + " v" + versionInfo.versionName;

            //Includes the updates as well so users know what changed.
            String message = mActivity.getString(R.string.updates) + "\n\n" + mActivity.getString(R.string.eula);

            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.putBoolean(eulaKey, true);
                    .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {

						public void onClick(DialogInterface dialog, int which) {
							// Close the activity as they have declined the EULA



Download Sample Project

Android Dev Digest

Get the best Android Developer posts delivered weekly to your inbox.

Don't worry, I wont spam (I hate that stuff too).

  • Chuck Brooks

    Thanks for eliminating some clerk-typist work that has the stellar advantage of being thought through and tested.

  • Donn Felker

    No problem. Enjoy!

    Sent from Android

  • søgemaskineoptimering københav

    TERA’s UI is also completely modular, meaning that players can move it around and generally customize it to their liking without resorting to hacks that violate the EULA or throwing up their hands in frustration. This is a far cry from previous Korean …

  • Modern Bedroom Sets

    These include fancy screensavers, backgrounds and other adornments for your Mac. When you install these freebies you are prompted to accept an End User License Agreement (EULA). This EULA asks for your permission to spy on your browsing habits, …

  • Decorating Small Space

    These include fancy screensavers, backgrounds and other adornments for your Mac. When you install these freebies you are prompted to accept an End User License Agreement (EULA). This EULA asks for your permission to spy on your browsing habits, …

  • Thomas


    Thomas from India

  • Jckimble

    This is a good way for a EULA but if you update alot you get alot of overhead so it should be better to use
    if(versionInfo.versionCode != prefs.getInt(EULA_PREFIX,0)){
    editor.putInt(EULA_PREFIX, versionInfo.versionCode);

  • Decorating Small Space

    limit to creativity. for all those bedroom is the room to unwind, well after the completion of his work or the other. bedroom with cheerful shades of pink shades really enjoy doing among teenagers and children in general. …

  • Karen Lee

    In the apps department, the iPhone is currently leading over Android phones. To date, there are about 230,000 apps available in the Apple Store for the iPhone device. In comparison, there are some 70,000 apps for Android phones. These numbers are changing daily, as more and more apps are added to each group. But according to industry experts, at the rate that apps are now being produced, it is likely that by the middle of 2012, there will be more Android apps than iPhone or iOS apps (iOS is the operating platform for Apple products such as the iPhone, iPod Touch, and iPad).

    One reason why Android apps will soo

    best android apps

  • Decorating Small Space

    When it comes to home décor, there are
    basics that many of us are not

    What about for a very
    small space
    ? “Make a
    small space
    feel as large as

  • Quality Furniture

     you can live in the space before you start decorating, that’s even better. “To be able to try the space on for a little while and then ease your way into the decorating is always good,” Carrier says.

  • Small Apartment Furniture

    A slightly different approach here – this code is designed to present
    the EULA dialog every time the version number changes – whenever you
    update the app. This means you can also display a message with recent
    changes and updates, which is a handy feature.

  • payday loan payday loan

    This is not really an answer to your
    question, so I’ll make it a comment: If it’s OK that people copy,
    redistribute and reverse-engineer your program, should you perhaps
    license it under a free software license? A very simple version is the
    three-clause BSD license, which also includes a warranty disclaimer. If
    you want to protect against others taking your code and not re-sharing
    it under the same license, something like the GPL is more appropriate.

  • Dining Kitchen Set

    Does that not sound like a closed eco system? by
    solitare_pax (5086 comments ) June 13, 2011 8:12 AM PDT Yes, it does
    sound like a closed eco system; however, we are still dealing with many
    fractured ecosystems; Kindle, Nook, Android, Windows, Linux, …

  • john

    nice work, thanks for sharing

  • Anonymous

    Android operating system has taken the world by storm, mobile application development for a while time. Of course, it is becoming less and less the number of applications available for the platform than other platforms like iPhone, BlackBerry and Symbian, but it is certain that Googles Android has already begun to spread its tentacles to other handsets. His recent earnings call, the T-Mobile announced it had sold its millionth mobile G1 with Android open source operating system, which means that Google has just six months later. All this means that it is a remarkable achievement considering the incredible anticipation and fervor for the iPhone.

    Los Angeles Website Design

  • Will

    There seems to be a problem with the above code.  If you open your app then hit the back button, the EULA message goes away without having to accept it.  It will still be there next time you start the app, but technically the user will never “have” to accept it.

  • WillP

    I meant to add this…

    If you just add .setCancelable(false) to your AlertDialog.Builder, you can bypass this issue and force either an Accept or Refuse.

  • Exanozz

    Is there any way to disable the search button ? If they hit the search button, the EULA will go away without having to accept the EULA itself. At the moment, the only workaround i’m finding is to code the search function to oblivion outside of the EULA itself.

  • Mitch Chauvin

    To prevent the SEARCHkey (SEARCH button) and potentially other keys from accepting the EULA, you should use the setOnKeyListener() to override the onKey() method of the AlertDialog “builder” specifically. This is because theAlertDialog “builder” will be on top and will be handling key events when the dialog is displayed.

    EXAMPLE SNIPPET: This will cause all keys to be ignored (including the SEARCHkey), except for the HOMEkey!

    AlertDialog.Builder builder = …

    builder.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialoginterface, int keyCode, KeyEvent event) {   if ((keyCode == KeyEvent.KEYCODE_HOME)) {   return false;  } else {   return true;  } }});

  • hire a website developer

    I just read through the entire article of yours and it was quite good. This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post.
    hire web developers | website developers for hire

  • Sdfsdf

    coach bags well designed for sale.
    coach outlet handbags high replica online.
    coach purses high quality for cheap.
    coach outlet store onsale wholesale for cheap.
    coach online wholesale online.
    juicy couture cheap online for sale.
    cheap juicy couture wholesale for cheap.
    discount juicy couture fashion designed for sale.
    discount juicy handbags high quality for sale.
    cheap juicy handbags wholesale online for cheap.
    juicy handbags cheap for sale.

  • outsourcing web developers

    Interesting disccusion made me feel educated by. I hope to see more blogs like yours. Keep it up, I’ll checking your new stuff then. Thanks.

  • karthik K

    Adding  builder.setCancelable(false) will  make the back button redundant and the android User Experience of getting out of the application on presseing the back button would be Lost. This would look like a forced way of either accepting or rejecting.
    It would be better if  one over rides the method oncancellister, it would look more appropriate;

    builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // TODO Auto-generated method stub YourActivity.finish(); } });

  • Chanel bags

    Armitage, who coach outlet online is yet to register Burberry Scarf a try in this year’s tournament, is Coach Outlet the second England player Chanel bags to receive a ban, after lock Courtney Lawes received Louis Vuitton Shop a two-match suspension for Handbags Outlets recklessly striking an opponent during a clash Coach Purse with Argentina.It has been Gucci Shoes a controversial campaign for England, with two members of Prada Handbags coach Martin Johnson’s staff not allowed to be on the ground for their crucial Christian Louboutin Shoes win over Scotland after being found guilty of illegally tiffany rings switching balls Moncler Sale in their previous match against Romania.On Estebanez, a statement the north face outle on the four-yearly competition’s official website read: “Estebanez was suspended by Independent Judicial Officer Christopher Quinlan QC (England) in accordance with the Rugby World Cup 2011 Disciplinary process.

  • Anonymousême-envisager-de-penser-acquisition-de-deux-paires-de-lunettes+13086445

  • danshengbojue

    Just only check out the cool gucci handbags that on sale in our reputed gucci online store. All the bags  that are really good and excellent and worth for you to own one in hand. Such gucci bagswhich seems to be also as  important as the jewelry that for these women, especially when attend some  important parties and occasions, which seems to be a necessary, so just come to  our gucci outlet to own one.

    It is household that the moncler coats that are all around given  that will while beyond. So especially appealed by the young people. Such brand  that are popular both among the women  moncler and men moncler, all  come along with the most fashion design that make such clothes popular among  the market. Come to our discount monclerfor more information.

    The flouring bags that on sale in these louis vuitton outlet storethat you  may disturbed which one to buy. However all these louis vuitton store that are definitely high quality designed as  well? as fashion design in appearance. You  can find such classic design bags that are popular among the bags market,  especially in these louis vuitton outlet.  No matter you can going to buy a bags for working, travel, or attending some  important parties, then the louis  vuitton handbags that would be a necessary.

  • Elegantfen

    Christian Louboutin Outlet, Save Up To 75% On New Style

    Shop The Latest Christian Louboutin, Jimmy Choo, Herve Leger, Manolo Blahnik From Up to 70% Off the Latest Designer Styles.

  • Marcio Andrey Oliveira

    Thanks for sharing.

    It is exactly what I was looking for.


  • Coach Factory Outlet

     Coach outlet online Leading American designer and maker of luxury lifestyle handbags and accessories.Large market in Europe and Canada,UK,USA etc.Welcome to Order!2011 New Style arrive,Free Shipping!

  • Elegantfen

    Shop The Latest Christian Louboutin & Jimmy Choo & Herve Leger & Manolo Blahnik From Outlet, Up to 70% Off the Latest Designer Styles.

  • Anonymous

    At the press briefing, Crowley dismissed the speculation cheap coach bags that a
    cheap coach purses bilateral dialogue mechanism
    cheap designer handbags would replace the six-party.
    coach handbags for cheap talks participated by
    cheap chanel handbags during the second
    cheap gucci handbags other four countries — China,
    cheap louis vuitton handbags south of the nation’s capital,
    prada handbags for cheap accelerate early
    cheap juicy couture handbags recovery and prepare for
    jimmy choo handbags sale will contribute to a
    cheap marc jacobs handbags Central Bank
    cheap tory burch handbags defense minister
    discount fendi handbags on July 25 in a joint
    hermes handbags birkin on Athens from
    cheap designer shoes South Korea, Japan and Russia.
    gucci shoes for men necessary measures
    gucci shoes for women the South Korean
    gucci shoes for cheap government has made
    gucci mens shoes several attempts
    gucci women shoes Within the six-party process,
    dolce gabbana shoes for cheap of government-level
    louis vuitton shoes for men to adopt mandatory retaliatory
    lv shoes for women discussions, not just with
    louis vuitton shoes for cheap the South Korean government  
    timberland boots for men of the votes.
    women timberland boots assistant administrator
    polo shoes for men the United States, but other
    polo shoes men countries, as well,” he stressed.
    coach boots on sale We still have a large number
    cheap coach sandals of miserable, hungry people
    gucci boots for women stake in Porsche
    gucci sandals for women structural measures  
    cheap designer wallets fiscal conservation
    cheap coach wallets and this contributes
    cheap chanel wallets are able to be not
    cheap louis vuitton wallets told reporters the
    cheap dg wallets stake in Porsche
    cheap designer sunglasses to world instability,”
    cheap carrera sunglasses of non-objection with respect
    cheap oakley sunglasses are able to be not
    cheap coach sunglasses Borlaug said in May 2006
    cheap louis vuitton sunglasses at an Asian Development Bank
    cheap chanel sunglasses forum in the Philippines.
    cheap gucci sunglasses He urged the Chinese government
    cheap dg sunglasses measures against US manufacturers of agricultural products and automobiles.

  • contemporary bathroom vanities

    Enjoy this awesome app as the iphone lock replacement for your android phone. 1. … This EULAgrants you no rights to use such content.

  • Online Modern Furniture

    After all, Microsoft’s EULA states ‘By using the software, … all manner of useful apps – mostly for free, thanks to Google Android’s open-source platform. …

  • hosting server

    Excellent creativity.Every one looking for this kind of valuable tips.All the points are explained very clear mind.

  • Create an Online Shop

    U have made an interesting blog..Thanks for sharing !!

  • routestir

    Cheers! Makes the steps easy and I like the responses for lessening the upgrade EULA screens as well.

  • Shygar

    To disable the back and search buttons, I added this code after the .setNegativeButton call:

                        .setOnCancelListener(new DialogInterface.OnCancelListener() {
                            public void onCancel(DialogInterface dialog) {
                                // Close the activity as they have declined the EULA

  • sbirje

    Good post. Helped get my first EULA integrated quickly. BTW, if anyone runs into the following error on,

    “The method onClick(DialogInterface, int) of type new DialogInterface.OnClickListener(){} must override a superclass   method”

    then here is a solution,

  • 624415672

     Ces méthodes n’ont toutefois pas la fiabilité que certains veulent bien leur prêter.millions d’abonnés en France au 31? sac louis vuitton Mais dans le même temps, la dette publique du pays a continué d’augmenter, davantage qu’attendu, atteignant le niveau record de 85,8% du PIB, a aussi annoncé l’Insee vendredi.?pourrait?clients de Bouygues Telecom ont demandé au 15?                          FTVi avec AFP                                                                      Des? sac vuitton Cette accumulation d’expertises a provoqué un débat passionné où tout le monde était perdu. sacs louis vuitton1 vendredi 30? louis vuitton site officieldécembre 2011. La saisine concerne également le budget rectificatif 2011 adopté le même jour. louis vuitton pas cher

  • Søgemaskineoptimering

    EULA vs simple disclaimer for Android App. up vote 1 down vote favorite. 1. I’m about to release a free app to the Android Market, and am unsure … This is not really an answer to your question, so I’ll make it a comment: If it’s …

  • Abc

    it was much useful, thaks

  • Rob Cozzens

    Thank you! This was very helpful.

  • ss

    Thank you.

  • filon

    to disable back buttons etc just put dialog.setCancelable(false)

  • AP

    Thanks for the information. You have made this process painless!

  • Test Bob


  • elijah123467

    Thanks works great!!!

  • Gurpreet Hanjra

    Very useful. Thanks!

  • Rahul

    Thanks allot. it saved time and effort.

  • Jared

    I am wondering how I might use two external text files with this, for eula and updates, instead of the implemented strings. Any pointers?

  • Donn Felker

    Yeah you could create text files and put them into the assets/ folder. Give them a name such as eula_1.txt and then use the same logic as above. Instead of using the resources you simply open the text file through getAssets() and then put the text into the field that you want. I hope that helps.

  • Newbie

    Hi, I’m fairly new to app developing and I followed your instructions however in android studios it is saying that it can’t resolve symbol R. Please could you let me know if there’s a solution to this? Thanks