Code example for ScheduledThreadPoolExecutor

Methods: scheduleAtFixedRate

0
 
public class NotificacaoService extends Service {
 
	@Override 
	public int onStartCommand(Intent intent, int flags, int startId) {
		ScheduledThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(1);
		long delayInicial = 0;
		long periodo = 10;
		TimeUnit unit = TimeUnit.MINUTES;
		pool.scheduleAtFixedRate(new NotificacaoTask(), 
								delayInicial, periodo,unit);
		return START_STICKY;
	} 
 
	@Override 
	public IBinder onBind(Intent intent) {
		return null; 
	} 
	 
	private boolean estaConectado() { 
Experience pair programming with AI  Get Codota for Java