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

Automatic Scrolling View pager page with few interval

I have used android view pager to display images and text now what i want is that smothly scrolling pages after few seconds and with animation? Its works but not smothly viewpager pages scroll. Timer call mCountDownTimer = new…
0
votes
1 answer

BlackBerry - App freezes when background thread executing

I have a BlackBerry App that sends data over a web service when a button has it state set to ON. When the button is ON a timer is started which is running continuously in the background at fixed intervals. The method for HttpConnection is called as…
Sarah
  • 1,895
  • 2
  • 21
  • 39
0
votes
4 answers

Timer doesn't stop with the if else

public static void randomN () { int requestTime = 2; if(requestTime > 0) { requestTime--; myTimer.scheduleAtFixedRate(new TimerTask() { public void run() { int randomx = (int) (Math.random()*6+1); …
morgothraud
  • 61
  • 1
  • 2
  • 10
0
votes
2 answers

Timer and TimerTask Java

I want my program to print Hello User, a ten seconds later print Ten Seconds Have Gone By, finally, a few seconds later print Goodbye User. I just don't know what or how to start to do this. Thanks Here's the code: import java.util.Timer; import…
0
votes
1 answer

android using TimerTask and execute when screen is off

In my app I want some action to be executed on specific time (not delay). I've come to use TimerTask, which works fine as long as the screen is ON. I've read in some places I have to use wakelock to get it work while screen is OFF. Everywhere it is…
SagiLow
  • 5,721
  • 9
  • 60
  • 115
0
votes
1 answer

one receive method getting null data

In my code, I am starting timerTask when broadcast message received. Here I displayed code of two classes. 1. broadcast receiver. 2. XML parsing. my Question is when I call timerTask, at scheduled time Timer call & I get all data into xml class.Like…
NovusMobile
  • 1,813
  • 2
  • 21
  • 48
0
votes
0 answers

Creating a new TimerTask from a separate class, JAVA

The primary chunk of my code is presentationController (extends JFrame). Within that, I create an object of type scrollPane = projectsScrollPane(); (extends JScrollPane). I also create an object of type presentation. The object scrollPane has…
Michael
  • 169
  • 2
  • 2
  • 9
0
votes
0 answers

OnStop() OnPause OnDestroy() not called

I created a chat application in android and for refreshing and getting new messages from otherside person, i used a TimerTask which runs a asynctask each 10 second... My problem is when i close this activity, timer task wont destroy and stop! even i…
0
votes
1 answer

Service That Call Another Service In A Timer

I have a timer in my TimerService with a task. Every 5 seconds it has to call another Service. @Override public void onCreate() { super.onCreate(); Log.i("ServiceDemo01", "Service Starts"); TimerTask…
paolo2988
  • 857
  • 3
  • 15
  • 31
0
votes
1 answer

Java: Call method by Timer, but changes made by called method dont remain outside TimerTask

I want that a particular method is called after a certain delay. I tried different aproaches likes timer, executor or handlers. They fullfill what they are supposed to do, but with a little exception. The delayed method call makes some changes in a…
Alika87
  • 301
  • 1
  • 5
  • 22
0
votes
1 answer

Change timer rate of a class that extends TimerTask

I was trying to make a music application which has a Sound class that extends TimerTask. A class Sound has an Audio Line that repeats the sound with a timer. My problem came when I was trying to change the rate. It would change the next time the…
Guille
  • 23
  • 1
  • 6
0
votes
3 answers

Implementation of periodic task in android

I want to create a small android app that would show the system time in periodic intervals after clicking on a button ( i.e. setting the activity up )...The code for button creation and setting the periodic activity via Intent goes like this…
Biswajit
  • 339
  • 1
  • 4
  • 9
0
votes
2 answers

How to change the way that timer schedules in TimerTask?

Here is the code snippet: Timer t = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { //change the timer rate of scheduleAtFixedRate here } }; //every 10 sec t.scheduleAtFixedRate(task, new Date(),…
Judking
  • 6,111
  • 11
  • 55
  • 84
0
votes
0 answers

Android - Cancel Thread.sleep in timer task

I schedule a timertask using timer and in that progress I use Thread.sleep( 10*60000) -> Sleep for ten minutes. And few times I need to cancel the running timertask and schedule a new one, as my timer task is in Thread.sleep for ten minutes I am…
user1810931
  • 638
  • 2
  • 11
  • 33
0
votes
1 answer

Android - Cancel the sleeping timer task

I am using timer and timer task in my app. I want to cancel the timer task by using .cancel() -> This works fine but few times I want to cancel the running timer task which is in sleep. When I use .cancel(), it doesn't work. Cancelling timer also…
user1810931
  • 638
  • 2
  • 11
  • 33