0

I want my push service to run after specific interval to push data to server at a duration of 1 hour.but it stops pushing data after 1 day, or sometimes when the app crashes though service is a seaparate process as it extends intent -service

    public class PushService extends WakefulRepeatableService 

    {
        public PushService() {
            super("PushService");
        }
        @Override
        protected void executeBackgroundService(Intent intent) throws Exception {

            new SmsLoggerforService(this, dayBeforeYesterday, currentDate, false)
                    .start();
            new CallLoggerforService(this, dayBeforeYesterday, currentDate, false)
                    .start();
        postDataperHour();
        }
        @Override
        protected long getRepeatingInterval() {
            return INTERVAL_HOUR;
        }
        // We can move it to super class using reflection, if Proguard is not being used.
        protected Intent getServiceIntent(Context context) {
            return new Intent(context,
                    PushService.class);
        }
}

referring to this tutorial https://randling.wordpress.com/2013/12/29/wakeful-and-repeatable-background-service-on-android/

  • What do you mean the app has crashed? did you have an unhandled exception? Well after that the results can be unpredictable. This class you have used isn't from the standard api. I would suggest that you read the 'Scheduling Repeating Alarms' section of the developer guide https://developer.android.com/training/scheduling/alarms.html – e4c5 Aug 15 '15 at 11:04
  • i am using inexact reapeating only .what is wrong in the blog, do you have any working example for the same. – srijan roy choudhury Aug 19 '15 at 05:30
  • I haven't bothered to read the blog there may or may not be someting wrong with it. My point was that there is a standard way of doing this (link in my previous comment) you should at least consider that approach before looking for third party solution.s – e4c5 Aug 19 '15 at 05:32

0 Answers0