/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
//          佛曰:
//                  写字楼里写字间，写字间里程序员；
//                  程序人员写程序，又拿程序换酒钱。
//                  酒醒只在网上坐，酒醉还来网下眠；
//                  酒醉酒醒日复日，网上网下年复年。
//                  但愿老死电脑间，不愿鞠躬老板前；
//                  奔驰宝马贵者趣，公交自行程序员。
//                  别人笑我忒疯癫，我笑自己命太贱。

package com.rest.client;

import android.app.Application;
import android.content.Context;

import com.google.android.gms.gcm.GcmNetworkManager;
import com.google.android.gms.gcm.PeriodicTask;


/**
 * The app-object of the project.
 *
 * @author Xinyue Zhao
 */
public final class App extends Application {
	/**
	 * Singleton.
	 */
	public static App Instance;

	{
		Instance = this;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		startAppGuardService( this );
	}


	public static void startAppGuardService( Context cxt ) {
		long   scheduleSec = 10800L;//
		long   flexSecs    = 60L;
		String tag         = System.currentTimeMillis() + "";
		PeriodicTask scheduleTask = new PeriodicTask.Builder().setService( AppGuardService.class )
															  .setPeriod( scheduleSec )
															  .setFlex( flexSecs )
															  .setTag( tag )
															  .setPersisted( true )
															  .setRequiredNetwork( com.google.android.gms.gcm.Task.NETWORK_STATE_ANY )
															  .setRequiresCharging( false )
															  .build();
		GcmNetworkManager.getInstance( cxt )
						 .schedule( scheduleTask );
	}

}

@@ -2089,18 +2089,962 @@
 duleTask );%0A
+%0A%0A//%09%09Calendar notifyTime = Calendar.getInstance();%0A//%09%09notifyTime.add(%0A//%09%09%09%09Calendar.MINUTE,%0A//%09%09%09%092%0A//%09%09);%0A//%09%09long   current = System.currentTimeMillis();%0A//%09%09long   nextFireWindow = (notifyTime.getTimeInMillis() - current) / 1000;%0A//%09%09long   flexSecs       = 30L; // the task can run as early as 10 minutes from the scheduled time%0A//%09%09String tag            = System.currentTimeMillis() + %22%22;%0A//%09%09OneoffTask onceTask = new OneoffTask.Builder().setService( AppGuardService.class )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .setExecutionWindow(%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09%09%09  nextFireWindow + flexSecs,%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09%09%09  nextFireWindow + flexSecs * 2%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .setTag( tag )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .setPersisted( true )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .setRequiredNetwork( com.google.android.gms.gcm.Task.NETWORK_STATE_ANY )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .setRequiresCharging( false )%0A//%09%09%09%09%09%09%09%09%09%09%09%09%09  .build();%0A//%09%09GcmNetworkManager.getInstance( cxt )%0A//%09%09%09%09%09%09 .schedule( onceTask );%0A
 %09%7D%0A%0A%7D%0A

Add experimental code for OnceTask