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.
Here is the layout for the EULA:
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.
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.