2

We are designing an app that users use on a subscription basis. When the user pays for a particular period, a receipt is issued from our server valid for the duration. The app is designed to be used "offline", so it will only be connecting with the internet to get the receipt from the server.

When in "offline" mode, the app waits for the paid duration #-of days until it requires the user to pay again. We are having problems implementing this.

We first tried to use an always running background service. But after reading https://stackoverflow.com/a/2682130/5753416, http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/, we decided to use AlarmManger to schedule periodic alarms to check for the payment.

We are now facing problems with the alarm when the user changes the time/date. We are listening to Intent.ACTION_TIME_CHANGED and Intent.ACTION_DATE_CHANGED broadcast, but that isn't being broadcast when setting the date to the past.

My question is what is the right way of implementing a similar functionality. Any advice is appreciated.

edit

issues with the broadcast

ASOP bug issue

Community
  • 1
  • 1
fuadj
  • 434
  • 4
  • 10

1 Answers1

0

There is one solution what you need to do is check phone up time so you can schedule alarm for some time like may be an hour or depending on your freq. So what you need to do is check phone uptime + duration for which the user is paid if that passes then cancel his subs. The only extra thing u need to check is if phone restarts once net should be connected to access your service.

Ashish
  • 183
  • 9
  • The problem I faced with the alarm is it won't fire if you "rewind" the clock. e.g: if the current time is 8 and I set the alarm to fire after an hour at 9. If then the user sets the time back to 5, the alarm won't fire for 4 hours. This only gets worse when the date is also rewound. That is why I'm trying to listen to TIME_SET and DATE_SET broadcast. But that isn't working when the clock is set back to the past. I've included the links in my question regarding that problem. – fuadj Sep 04 '16 at 07:32