Question

I want to develop an android App with premiumn access which offer more possibilities to the user. The premium access is avaiblable for one month.After the one month, i want that the apps block the access. How can I manage it programmatically? Some precision: when the user get premium access, he can use the app without internet.So i want to put into the app a sort of Counter, which will count the number of day even if the apps is on,off or reboot.

I will be interrest if it is possible with j2me apps. Thank you

Was it helpful?

Solution

If you don't want to use subscriptions as told in the other answer:
Use SharedPreferences. Save a bool for knowing if the user is premium. Also save a String with the current time when changing the bool because the user enabled premium. On every initialisation of your app check if its already time + 30 days and continue accordingly.

Something like this:

//enabling premium:
long time= System.currentTimeMillis();
String sTime = String.valueOf(time);
SharedPreferences premiumpref = new SharedPreferences();
premiumpref = getActivity().getSharedPreferences("premiumpref", Context.MODE_PRIVATE);
premiumpref.edit().putString("time",strTime).commit();


//next start:
long time= System.currentTimeMillis();
SharedPreferences premiumpref = new SharedPreferences();
premiumpref = getActivity().getSharedPreferences("premiumpref", Context.MODE_PRIVATE);
String startTime = premiumpref.getString("time","0");
Long lStartTime = Long.valueOf(startTime);
if((time-lStartTime) >= (86400000*30)) //thats the number of ms in a day
{
    //premium is over
}

OTHER TIPS

You probably want to use google's in-app billing and sell them a subscription:

https://developer.android.com/google/play/billing/billing_subscriptions.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top