When we start to develop any commercial android application, we may need to develop a trail application which runs on user device for a specific time and force the user to buy the application to use it further.
We can accomplish this using one of the below three techniques.
- The first technique can be easily implemented. When user runs the application first time, save the date and time to a preferred preference or a file or to the database. And every time user runs the application compare the current date and time to see if the trial period of the application has ended. if so, finish() or terminate the application. But this technique can be easily broken by uninstalling and installing the application again. this allows the user to run the application for another trial period.
- The second technique is hard to break. But still can be broken. In this technique we can hard code an end date for the trail. All the users that download and use this application will stop being able to use the application at the same time. This technique is very easy to implement. User can break this technique by changing the date and time of the device manually. But I feel most of the user don't do this. But anyways this technique is breakable.
- Using the third technique, we can accomplish what we want. But this is bit tedious. And is the correct way of working for the trial application. This technique requires setting up of a web server and a database in the server. Whenever user starts the application, device should send the Phone Identification Number. To get the unique device identification number you can use the getDeviceId() of Telephony Manager. And to send the data to the Server you can refer my old blog post "Syncing data to the Server". It's not the exact post. But you can refer that technique to send the data to the server. Once the data is sent to the server, Server should check if there is an entry for that device using unique identifier. If not, it has to make a new entry with the current date and time. If the server has an entry for this device then, it has to just do a simple check to see if the trail period has expired. It then communicates the result of the trial expiration check back to the application.
The check has to be done in the onCreate() of the main activity. If the trial period has expired then application should pop up an Alert Dialog with a google play link to the full version or commercial version of the application. Include OK button in the dialog, by clicking on it, it should call the finish() to end the application.
Third approach is non breakable and the good to use. That's it. Happy coding.
No comments:
Post a Comment