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
5
votes
2 answers

how to call onUpdate() in AppWidgetProvider?

this is my code... String[] show = new String[2]; RemoteViews remoteViews; public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget"; public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget"; @Override public void…
user724861
  • 1,074
  • 3
  • 17
  • 33
5
votes
3 answers

Schedule multiple tasks in a single thread

I want to have a single thread maintain responsibility for multiple tasks scheduled at different intervals. I want to add and remove tasks from the scheduler. Are there any libraries that can help me with this. If not I will code my own just don't…
James
  • 3,597
  • 11
  • 47
  • 57
5
votes
1 answer

How can I change the stack size (of a thread) in my Android Application?

I'm getting a stackoverflow error in my service which is attached my to my main activity. Is there a way to change the stack size within my service ? I came across the Xss parameter, however, apparently its not available in the vm options…
utengr
  • 3,225
  • 3
  • 29
  • 68
5
votes
3 answers

Timed while loop not terminating

Running this code, I would expect it to increment the test variable for 5 seconds and then finish. import java.util.Timer; import java.util.TimerTask; public class Test { private static boolean running; public static void main( String[]…
5
votes
2 answers

How to use Java.Util.Timer

I want to make a simple program that counts seconds up until 100 using Java.Util.Timer The code below is the code I am using, however it simply prints all the numbers out at once without waiting a second between each one. How would I fix that?…
Neil M.
  • 689
  • 1
  • 8
  • 17
5
votes
2 answers

Android error: "Could not create epoll instance", or "Could not create wake pipe"

I have an Android app that uses a timer to call an AsyncTask every 5-10 seconds (using java.util.Timer and java.util.TimerTask). The AsyncTask gets image data from an Amazon AWS S3 database, and loads an ImageView for the main UI Activity. This…
gcl1
  • 4,070
  • 11
  • 38
  • 55
5
votes
1 answer

Android can't create handler inside thread that has not called looper.prepare()

I started developing an Android application that record a video and I need to gather the GPS location every 1 minute public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //…
user1331120
  • 247
  • 2
  • 3
  • 8
5
votes
2 answers

Throwing null pointerException in Timer.Schedule();

In the following code t.schedule(timertask, d.getDate(), 1000); is throwing NullPointer exception help me out Goal : My basic goal is to Run a method(every time after a fixed interval ) that will send some data to webservice from my android device…
user1448729
4
votes
1 answer

Java timer with not-fixed delay

I need a Timer that basicaly does something every t seconds. But I want to be able to modify the timer period at which the timer repeats the task. I wrote something like this: public Bot() { timer = new Timer(); timer.schedule(new Task(),…
Fofole
  • 3,398
  • 8
  • 38
  • 59
4
votes
3 answers

How to Wait for windows process to finish before opening file in java

I have a implemented a listener that notifies if we receive a new file in a particular directory. This is implemented by polling and using a TimerTask. Now the program is so set up that once it receives a new file it calls another java program that…
Eosphorus
  • 312
  • 3
  • 10
  • 19
4
votes
3 answers

iPhone equivalent of Timer and TimerTask for periodic tasks

I'm trying to port an Android app to an iPhone. On Android I could easily process data every 60 seconds by using a Timer class with TimerTasks using scheduleAtFixedRate: timer.scheduleAtFixedRate(task,15000, epochLengthMs); Thank you! Is there…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
4
votes
2 answers

Can I run timer at different intervals of time?

Actually i wanted to ask can i give value from database to a timer delay? Timer timer = new Timer(); TimerTask timerTask = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { …
Husnain
  • 137
  • 1
  • 9
4
votes
1 answer

How Do "App Lock" app work internally?

I need to develop app just like android App lock that opens password activity when app assigned application get launch. I have read below question but didn't find proper solution. I just want to ask that what service or method they are using? how to…
Roshni jain
  • 176
  • 7
4
votes
3 answers

Timer Task in java?

I have to do the timertask in java. The scenario is: I have to schedule a task for some delay intially. If i have clicked a button it will cancel the current Timer and then it will reschedule it. How to implement it in java? when i have used the…
Praveen
  • 90,477
  • 74
  • 177
  • 219
4
votes
2 answers

Difference between delay and period parameters of scheduleAtFixedRate() function of Timer in java

In java.util.Timer.scheduleAtFixedRate(TimerTask timer, long delay, long period), what is the difference between delay and period?
SteffyK
  • 67
  • 1
  • 1
  • 3