Creating an Android EULA Activity

What is a EULA?

It stands for end-user license agreement, and it is a legal contract between the developer of an application and the user of that application. Most developers “shrink-wrap” their application with the EULA agreement, not allowing users to access any part of the application without first clicking “Agree”. That is the type of EULA we will be creating.

Why is a EULA necessary for your Android app?

  • A EULA can give you the right to terminate the license or stop supporting the application without fear of legal repercussion.
  • A EULA allows you to provide your app on an “As Is” basis and disclaim warranties.
  • A EULA will allow you to limit your liability.
  • A EULA can restrict undesirable usage of your application such as spamming, hacking or reverse engineering.
  • A EULA will license the app to your user without selling them full ownership of the app.

Android Eula Activity

Create a reuseable EULA activity for your Android application.

Any application you plan on selling or giving away should have a EULA. I recently had to come up with one for an Android application. It had to be used by a few of the activities in the application because it had a bottom navigation menu and multiple entry points.

The EULA activity is below. It is using SharedPreferences to store the eulaAccepted variable. In real life, you would probably have a whole user object that you cache with SharedPreferences but then save to a remote API once the user accepts the EULA.

It would seem natural to display HTML in Android in a WebView and that was the other option. You just have to load the file path to the resource in WebView. With this method, just add an HTML file to the res/raw/ folder and access it by the resource id. This resource id is passed in with the intent when the activity is started.

Confirming the EULA sets the eulaAccepted variable. Canceling the EULA does nothing other than show a snackbar that tells you that you have to accept the EULA to continue.

The Android EULA layout

Here is the layout for the EULA:

Using the EULA Activity in other activities.

To “shrink wrap” your Android app with your EULA, just run the checkEula method below right after you call setContentView in onCreate on any Activity in your app users can enter from.

In the checkEula method, we see if the user has accepted the EULA by checking SharedPreferences and if they haven’t, we set the eula value in intent and start EulaActivity.

Raw EULA html resource file.

This is just a basic EULA that I copied an online EULA generator for this example. You can generate a EULA for your app at one of these sites for free:

You can access the complete Github gist here. And you can find the code used in an example project here.

Stephan Miller

Written by

Kansas City Software Engineer and Author

Twitter | Github | LinkedIn