Creating an Android Trial Application That Expires After a Fixed Time Period

Creating an Android trial application that expires after a fixed time period

Currently most developers accomplish this using one of the following 3 techniques.

The first approach is easily circumvented, the first time you run the app save the date/time to a file, database, or shared preferences and every time you run the app after that check to see if the trial period has ended. This is easy to circumvent because uninstalling and reinstalling will allow the user to have another trial period.

The second approach is harder to circumvent, but still circumventable. Use a hard coded time bomb. Basically with this approach you will be hard code an end date for the trial, and all users that download and use the app will stop being able to use the app at the same time. I have used this approach because it is easy to implement and for the most part I just didn't feel like going through the trouble of the third technique. Users can circumvent this by manually changing the date on their phone, but most users won't go through the trouble to do such a thing.

The third technique is the only way that I have heard about to truly be able to accomplish what you want to do. You will have to set up a server, and then whenever your application is started your app sends the phones unique identifier to the server. If the server does not have an entry for that phone id then it makes a new one and notes the time. If the server does have an entry for the phone id then it does a simple check to see if the trial period has expired. It then communicates the results of the trial expiration check back to your application. This approach should not be circumventable, but does require setting up a webserver and such.

It is always good practice to do these checks in the onCreate. If the expiration has ended popup an AlertDialog with a market link to the full version of the app. Only include an "OK" button, and once the user clicks on "OK" make a call to "finish()" to end the activity.

Creating an Android Trial app that expires after a certain number of actions

Since you don't want to allow the user to get the trial again if he reinstalls the app you will have to use the third technique where you send the data to the server because that is the only way to persist the count of button clicks and tie it to the device across app installs. So instead of using the time u can keep a count of the number of times the button have been clicked on the server. Also u can configure the number of button clicks you want to allow before the app expires instead of hardcoding in the app.

If you don't want to run your own server then you use Parse to store the number of clicks of the button and the user id. It is very easy to integrate.
https://parse.com/docs/android/guide#getting-started

How to make an Android application work only for some trial period

There is only one way to truly achieve this:

You will have to set up a
server, and then whenever your application is started your app sends
the phones unique identifier to the server. If the server does not
have an entry for that phone id then it makes a new one and notes the
time. If the server does have an entry for the phone id then it does a
simple check to see if the trial period has expired. It then
communicates the results of the trial expiration check back to your
application. This approach should not be circumventable, but does
require setting up a webserver and such.

There are other ways(such as storing installation date somewhere) but then if user uninstalls your app, that info will be gone and when he reinstalls there is no way to know if he installed before.

EDIT:
Ok, since you want to go with SharedPreferences way, here is an example:

private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
private final long ONE_DAY = 24 * 60 * 60 * 1000;

@Override
protected void onCreate(Bundle state){
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
String installDate = preferences.getString("InstallDate", null);
if(installDate == null) {
// First run, so save the current date
SharedPreferences.Editor editor = preferences.edit();
Date now = new Date();
String dateString = formatter.format(now);
editor.putString("InstallDate", dateString);
// Commit the edits!
editor.commit();
}
else {
// This is not the 1st run, check install date
Date before = (Date)formatter.parse(installDate);
Date now = new Date();
long diff = now.getTimeInMillis() - before.getTimeInMillis();
long days = diff / ONE_DAY;
if(days > 30) { // More than 30 days?
// Expired !!!
}
}

...
}

I haven't compiled this but should give you an idea.

Time limits for trial version of application

When your application is installed for the first time on the device, connect to your server and assign it a unique id for the device.

Every time the application is started, check for the expiration date corresponding to the device and show appropriate message when the trail period gets over.

Or otherwise, disable a few features and release them only when the user buys it.

Don't use SharedPreferences because the user can easily clear the application data and the time would be reset.

Android application should expire after 1 month of its release

Please see this question, it has a good answer.

I will give you my experience with trials. At first I tried just using the date on the phone, but then realized if they uninstall and re-install this can be bypassed. This could be fixed by storing the install date somewhere on the file system (hidden), but what happens if the user wipes data or finds the file?

I also tried to just check the date/time at a server anywhere (maybe your www site?), but this imposes restrictions on your application because they must have internet. Soon I realized the need for better license management, so the last solution was used.

The last solution would be to setup a server. You can use the device's unique ID (whichever you choose - I went with the Bluetooth MAC ID because my application requires bluetooth as well), post to a server to check if the user has a trial, if they don't I issue them one, if they do I check the expiration. Now I have complete control over when trials expire. Since my application is a business app that is used in the field, this is very handy if a potential buyer needs another week.

The only issue with the last solution is that if you plan on publishing to Market, you must use their payment system.

Good luck!

How can I make a time-limited trial application?

To echo what was written in the comments:

Have the device create a UUID, then send the UUID to a server like was mentioned. Every time the app is used or every couple days, which ever is more, check if the app trial has expired and should be disabled IN the Licensing Services policy. That way you can have the licensing service disable the application for you.

Create an application that will expire after a trial period

If you go with a date-based approached, it can be circumvented by a user's setting their date back (although I doubt people do this very often). An alternative is to allow the application to be started a certain number of times before expiring; this approach obviously ignores any date changes.

My preferred method is to disable parts of the application that are critical to normal use of the program but aren't critical to its evaluation (like the ability to save your work, for example). I do this with my own software, and then send them an unlocking code unique to their computer when they purchase the full program. One primary advantage of this approach is that the installed demo functions as a potential sales tool forever. I'd rather have my program always working to some extent; I don't think a "Sorry, this program has expired" message generates many sales.



Related Topics



Leave a reply



Submit