Reputation: 835
I have done an small App in Android, which I want to set as trial version for 2 days, after 2 days it should ask for a key. If the user uninstalls the App after expire date, he shouldn't be able to use the App without a key...
Upvotes: 0
Views: 2113
Reputation: 4220
Just use Android Licencing. It's pretty straight forward and awesome.
Anything more secure than that would be so much trouble. I don't think it's worth the effort for most apps.
http://developer.android.com/google/play/licensing/index.html
Upvotes: 0
Reputation: 10236
An idea could be release two versions of the app. One free version with some limitations or Ad's in it and another paid version of the app.
Upvotes: 1
Reputation: 13807
I don't know, how safe/secure it would be, but you could use SharedPreferences to store this data. Just a really small example:
On startup:
SharedPreferences prefs = getSharedPreferences("AppName", Context.MODE_PRIVATE);
boolean firstRun = prefs.getBoolean("first_run", true);
long currentTime = System.currentTimeMillis();
if(firstRun)
{
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("first_run", false);
editor.putLong("first_run_time", currentTime);
editor.commit();
}
else
{
long firstRunTime = prefs.getLong("first_run_time", 0);
long twoDays = 2 * 24 * 60 * 60 * 60 * 1000;
if(currentTime - firstRunTime > twoDays)
{
//Expired
}
else
{
//Not yet expired
}
}
Please note, that if the user uninstalls the app, and then reinstalls it, or simply deletes the applications stored data, the "timer" will reset!
A safer method would be to store this data in an online database, but thats more complicated to solve, and it would require internet connection all the time to check if the app is expired.
Upvotes: 0
Reputation: 16354
You need to setup a database which will be online assign a specific id to each device. If you are going to save the date of install in the SharedPreference or any local memory, the user can just remove it from his phone by simple clearing all the application data. He wouldn't have to uninstall it even.
So, every time a new user installs your application, you need to store the date of install corresponding to each device in your online database. Everytime the application is started, you need to ask the server for the date of install corresponding to that device and let the user proceed iff it is in the trial period, otherwise ask him for the key there.
Upvotes: 0