-
Andy G
java android service timer timertask
i wanted to check the actual time every 5 mins in a service and mute or unmute the phone depending on the time. earlier i tried to use a while(true) with thread.sleep(300000) at the end, but it crashed always with a ANR, so i tried to use a timer task but now it crashes right after the line AudioManager audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE); with an NullPointerExceptionpackage de.nathan.android.droidschool;import android.app.Service; import android.content.Con
-
meewoK
java tomcat servlets timertask
I suspect an exception could make the TimerTask stop running in which case I most likely need a second timetask to monitor that the first is still running?UpdateThanks for the answers. I had inherited this code so a bit ignorant…I just saw that if I throw an uncaught exception in my job the TimerThread ceases to run forever. Run method of TimerThread showed that if an exception is thrown, my scheduled thread never runs again.public void run() {try {mainLoop();} finally {// Someone killed this
-
Brad Larson
java timer timertask
I tried to create a timer and a timertask but I can’t get it to work :(“Your post does not have much context to explain the code sections; please explain your scenario more clearly.”?ErrorTimer.sched(TimerTask, long, long) line: not available Source not found.Exception in thread “main” java.lang.NullPointerException at java.util.Timer.sched(Unknown Source) at java.util.Timer.schedule(Unknown Source) at Game.<init>(Game.java:42) at Game.main(Game.java:25)Game.javaimport java.applet.*; impor
-
Ankuj
android android-asynctask timertask
I have scheduled a AsyncTask using a Timer by following codepublic void toCallAsynchronous() {TimerTask doAsynchronousTask;final Handler handler = new Handler();Timer timer = new Timer();doAsynchronousTask = new TimerTask() {@Overridepublic void run() {// TODO Auto-generated method stubhandler.post(new Runnable() {public void run() {try {if(mLoggedIn){DownloadRandomPicture download = new DownloadRandomPicture(this, mApi, CLIENT_ID, mImage);download.execute();}} catch (Exception e) {// TODO Aut
-
ciyo
android callback qr-code timertask
I am using a TimerTask() in previewCallback for an app. However, it stops to work. I am newbie for Android development and I have no idea what or where is the problem. I am trying to reactive the camera preview after 5 seconds. I tried same code lines from if( isQrCodeScanned ) to phoneCamera.autoFocus(autoFocusCallback); in an onClick() function without using timer and it works. When I tab the button, camera preview is reactivated. However, for TimerTask(), it crashes.private Timer timer; . .
-
Sergey Belinskiy
java jsp ioexception timertask
i’m trying to make simple scheduler using Timer and TimerTask classses see the code below, inside of the task i just want to print “Hello, World!” on the page, but it throws IOException: Stream closed. Please help!JSP page code:<% Test t = new Test(out);%>Test class code:public class Test {public Test(JspWriter out){Timer timer = new Timer();LpdbTask lTask = new LpdbTask();lTask.out = out;timer.scheduleAtFixedRate(lTask, 1000*5, 1000*60);} }LpdbTask code:public class LpdbTask extends Timer