Questions tagged [android-timer]

70 questions
0
votes
0 answers

Broadcast Service ACTION_BOOT_COMPLETED delay android

could you please explain me why i can't start my activity from broadcast reciever with 5 sec. delay in this way. Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { …
0
votes
1 answer

Timer in android java

I have 2 activity in activity2 i have a timer when activity create timer is started in activity on_Destroy i put timer_task.cancel(); but When opened the activity2 for the second time is create new timer task and not Canceled or destroyed the…
Android
  • 31
  • 1
  • 6
0
votes
0 answers

Timer inside a service doesn't work properly on device restart

I am starting an android service and an activity after device restart using a broadcast receiver.Inside service I use a timer as follows. But after starting service the timer doesn't work properly. Timer triggers continuously without any time…
0
votes
0 answers

How to run timer one after another in android?

How to run timer one after another? for eg: I am using two edittext and one button, after giving input to 2 edittext as 1 and 2(in minutes), the timer should first complete the first given input and then to start the 2nd input. Then when i click…
Shadow
  • 6,864
  • 6
  • 44
  • 93
0
votes
1 answer

Timer code that can run in background

I want a timer code that can run in background and only stops when I want to. Basically, there are two buttons. Start timer and stop timer, and when I press the start button it starts the timer and it should automatically run in the background also,…
0
votes
1 answer

android - countdown with decreasing time

In my game the user gets a point when he clicks a button within five seconds. Now I want the timer to decrease the time with every point the user gets - so e.g. with zero points the user has five seconds, and when he has one point he gets only 4.5…
jle
  • 686
  • 1
  • 8
  • 24
0
votes
1 answer

How to initialize circular animated timer at specific position in android

The timer always starts from the top, and I want it to start from some initialized position with some part already drawn. I took reference from this tutorial. This is my MainActivity: public class MainActivity extends AppCompatActivity { …
0
votes
1 answer

How to measure time in Android?

I am developing a Human Activity Recognition Android application and I have to measure both time being sedentary (static) and time spent active. At first, I thought to store a long variable in the sharedPreferences and increment it every 5 seconds…
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
0
votes
1 answer

Why does the following Count down timer in android always shows 00:01 at the end?

String hms = String.format("%02d:%02d", TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished)), …
sofs1
  • 3,834
  • 11
  • 51
  • 89
0
votes
2 answers

Shared Preferences causing null pointer exception when switching fragments

I am working on a fragment based Android app. In this app, it scrapes some information from websites and stores it in SharedPreferences to compare what the user wants to display. So the user enters some map that they are looking for, the app scrapes…
0
votes
0 answers

Android : Take a photo every X seconds and save it on SD Card without user clicking a button

Disclaimer : I am new to Android Development I am trying to build an android application which can click photos every X seconds without the user clicking the button multiple times. The user should only click on the button to stop the timer. I read…
0
votes
2 answers

What's the best way to make a Count Down Timer?

I am wondering if this is the best way to make a timer of 1 minute on Android: new CountDownTimer(60000, 1000) { public void onTick(long millisUntilFinished) { } public void onFinish() { } …
MauroAlexandro
  • 347
  • 3
  • 6
  • 18
0
votes
3 answers

TimerTask inside Fagment

Basically, I need to use a TimerTask inside a fragment but this error appears: 04-04 15:01:02.710 28397-28528/com.example.sdilab.pap E/AndroidRuntime: FATAL EXCEPTION: Timer-1 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the…
António Paulo
  • 351
  • 3
  • 18
0
votes
1 answer

How to implement coundowntimer to run beyond the limit?

i am working on a application in which i am using CountDownTimer for timer purpose which runs from the start time given to upto 0 and then receives a callback in onFinish(), but i want it to run in negative value. say, if timer is set for 1 minutes…
Tushar Purohit
  • 524
  • 7
  • 25
0
votes
1 answer

Unable to reschedule timer in Android

i am working on a simple app. in my app i am using timerTask like this: TimerTask saveData=new TimerTask() { @Override public void run() { saveDatatoFile(); } }; i call TimerTask in onCreate() of my activity like: int…