Questions tagged [timertask]

Timertask is a Java API class. Logically it represents a task that can be scheduled for one-time or repeated execution by a Timer

A TimerTask implements Runnable, also has a method to cancel the scheduled task, if required. It is used with java.util.Timer (Swing timer fires action events).

A concurrent package contains several classes that are similar to TimerTask by concept but provide additional funcitonality.

917 questions
0
votes
1 answer

Boggle game loop logic

I'm writing a console Boggle game and the gameLoop logic isn't quite what I think it should be. My basic game loop method is: public void gameStart() { timer.schedule(new BoggleTimerTask(1),0); gameActive = true; …
Jeff D
  • 1
  • 3
0
votes
0 answers

How do I know my whole android application is not running anymore or closed?

I have a timer where I perform a task for instance, every 10 seconds. The problem is I want to know my application has been closed already in any activity I am in, so I could end my runnable timer and the task within it. I successfully implemented…
Compaq LE2202x
  • 2,030
  • 9
  • 45
  • 62
0
votes
1 answer

Timer/TimerTask Error

I just started with programming of android applications and right now I have a problem with timer and timer tasks. In my app I use a timer to update the UI but when I start to test it gets an error and I have to force close it. Here is my timer…
Salexes
  • 187
  • 1
  • 2
  • 20
0
votes
3 answers

Java: Thread/task expiration after specified milliseconds

In Java is there a sane way to have a thread/task run continuously and then end after a specified run time (preferably without using several timers)? For instance, if I have a TimerTask, there doesn't seem to be a way to schedule that task to end…
skeryl
  • 5,225
  • 4
  • 26
  • 28
0
votes
0 answers

return to original class without retaining current class

I have class (MC) and there is a timer inside it to perform a task several times. After finishing, I want to go back to the original class (Main) without retaining MC class. if I call method (afterFinishingMC) from MC I'm concern there could be…
HJC
  • 3
  • 3
0
votes
1 answer

Android: How to run a Task inside another Task (TimerTask)

I have the following code: //Task that runs in background thread and posts results private class NewsWorkerTask extends AsyncTask> { @Override protected void onPreExecute() { } @Override protected…
Eric Bergman
  • 1,453
  • 11
  • 46
  • 84
0
votes
2 answers

Shutdown hook is not killing executor

I have the following code: public class Driver { private ExecutorService executor = Executors.newCachedThreadPool(); public static void main(String[] args) { Driver d = new Driver(); d.run(); } private void run() { …
user1768830
0
votes
0 answers

Cannot Reach private void startServiceTimer When Debugging - Android

I'm attempting to debug my app, but when I attempt to reach the code starting at: private void startServiceTimer() { However when eclipse reaches the line: startServiceTimer(); It should jump to: private void startServiceTimer() { However it…
user2533377
  • 45
  • 1
  • 2
  • 6
0
votes
2 answers

Android Timer update UI between multiple tasks

I have tried multiple ways to have a single persistent timer update the ui in multiple activities, and nothing seems to work. I have tried an AsyncTask, a Handler, and a CountDownTimer. The code below does not execute the first Log.i statement....…
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
0
votes
1 answer

TimerTask returning nullpointer Exception

I have piece of code which runs every 5 seconds in TimerTask, Also using ExecutorService to span a thread for each pool. if(!alertingPools.isEmpty()) { Object[] Pools = alertingPools.values().toArray(); executorService =…
user2325703
  • 1,161
  • 1
  • 8
  • 10
0
votes
1 answer

repetitive time call from a URL using JS

I have the code below that will grab an RSS feed and display it as a custom html feed shows these as scrolling text on a page. " I would like to know how to make a timed call back to the RSS URL to display new information and drop out non current…
adroit18
  • 1
  • 1
0
votes
2 answers

TimerTask causing "Access closed cursor" force close

I have a TimerTask that is causing my app to crash when I go to a different Intent. Here is the error: 06-06 02:45:54.884: E/AndroidRuntime(602): FATAL EXCEPTION: main 06-06 02:45:54.884: E/AndroidRuntime(602): android.database.StaleDataException:…
scarhand
  • 4,269
  • 23
  • 63
  • 92
0
votes
0 answers

java - TimerTask - why my code behaves like that?

I wrote the following code: private void Button_StartMouseClicked(java.awt.event.MouseEvent evt) { java.util.Timer().schedule( new java.util.TimerTask() { …
Frank
  • 2,083
  • 8
  • 34
  • 52
0
votes
1 answer

Process running in background with timer Task killed by android

I have app with timer task,my app is save the current cell ref and neighbor cell into csv at interval time. My problem is,when i start the app and press 'HOME' screen at device and then i running other app, while i come back to my app via…
0
votes
1 answer

Send notification every x seconds

I'm doing an app that checks the live scores. I don't know if it's the best way, but I created a Timertask, a Service and and Activity to notify. The Timertask checks every x seconds if the score changes and if it changes, informs the Service. If…
qwertzuiop
  • 685
  • 2
  • 10
  • 24