2

I have been making an android kiosk app. It's basically a launcher on which other apps will run upon. The users will have to subscribe to it. Now, I want to check for the days left for the subscription to expire, I have been trying to do so with the CountDownTimer class, but it lags. The app won't be having a connection to the internet always. What should I use?

ADM
  • 16,256
  • 11
  • 37
  • 69
Mayank Raj
  • 841
  • 1
  • 11
  • 21
  • Use [AlarmManager](https://developer.android.com/reference/android/app/AlarmManager). – ADM Jun 10 '18 at 04:50
  • But I also need to show the user the number of days and hours left for the subscription. How will the AlarmManager help? – Mayank Raj Jun 10 '18 at 04:53
  • `AlarmManager` will help you setting the alarm for a specific date and time. After setting alarm just save this time in Shared Preference and show the user remaining days left with calculation . Also Read about Reboot in `AlarmManager`. – ADM Jun 10 '18 at 04:55
  • Okeh thanks, I understood. – Mayank Raj Jun 10 '18 at 04:57
  • Possible duplicate of [Android - how to set an alarm to a specific date](https://stackoverflow.com/questions/4700285/android-how-to-set-an-alarm-to-a-specific-date) – ADM Jun 10 '18 at 04:59

1 Answers1

0

of course you should not use timercountdown cuz this will consume the resources. What u need is to check the first day of the subscription and the current day, then subtract that from the total number of days the user or the subscriber has subscribed for (or payed for) that's assuming that u know the exact number of days the subscription will be running and valid during.

EDT: This will put in ur hands the number of the remaining days so that u can display that to the user. I hope this answers ur question, If there is other questions regarding that or any thing that is not clear pleas ask in the comment section.

Mohammad Elsayed
  • 1,275
  • 1
  • 11
  • 30