timer

Android execute a function after 1 hour

泪湿孤枕 提交于 2019-12-18 07:00:05
问题 I have an android application where I am storing user's data on database when he/she activates the app. My app requires the user to stop the application manually in order to remove its entry from the database and along with that other services which keep running when the app is activated. So I want to write a function which will be executed after every hour (when the app is activated) and will give a notification to user just to remind him/her about the service which is running .If the user

Android - Want app to perform tasks every second

回眸只為那壹抹淺笑 提交于 2019-12-18 05:59:15
问题 I'm trying to get my countdown app to perform its function of updating my current time and date TextView and fire off its MyOnItemSelectedListener every second so that the app counts down dynamically instead of just when onCreate is initiated. If there is a more efficient method then rapidly firing off MyOnItemSelectedListener I would appreciate the criticism. public class TheCount extends Activity { TextView description=null; TextView dates=null; TextView times=null; TextView output=null;

Why does System.Threading.Timer stop on its own?

吃可爱长大的小学妹 提交于 2019-12-18 05:37:46
问题 I'm doing a small test project before I use System.Threading.Timer in a Windows Service project. It's working wonderfully, however the timer stops on its own after a minute or two. The full source for the test project is: using System; using System.Windows.Forms; using System.Threading; namespace studyTimers { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { TimerCallback timerDelegate = new TimerCallback(tick)

Android timing in OpenGL ES thread is not monotonic

橙三吉。 提交于 2019-12-18 05:25:34
问题 I'm measuring time interval for looped animations/particles/etc in my Android app. App is a live wallpaper so it doesn't prevent system from scaling clock down for power saving. Because of this all methods to measure time intervals between last frames doesn't measure monotonic time - I experience animations inconsistently slowing down and speeding up. I've used all possible methods to retrieve system time - all of them are not monotonic (even SystemClock.elapsedRealtime() and System.nanoTime(

How to display the timer in android

自古美人都是妖i 提交于 2019-12-18 04:08:29
问题 I want to display the timer in TextView in the format of like [ 19:59].so when i click the start button ,the timer will display like this for example,i want to set upto 20 mintues,it will display like [19:58][19:87].can anyone give some ideas or example code? 回答1: You can use the CountDownTimer . http://developer.android.com/reference/android/os/CountDownTimer.html TextView _tv = (TextView) findViewById( R.id.textView1 ); new CountDownTimer(20*60000, 1000) { public void onTick(long

Seconds CountDown Timer

给你一囗甜甜゛ 提交于 2019-12-18 04:03:08
问题 I have a lblCountdown with an int value of 60. I want to make the int value of the lblCountDown decrease with seconds until it reaches 0. This is what I have so far: private int counter = 60; private void button1_Click(object sender, EventArgs e) { int counter = 60; timer1 = new Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 1000; // 1 second timer1.Start(); label1.Text = counter.ToString(); } private void timer1_Tick(object sender, EventArgs e) { counter--; if

High-Performance Timer vs StopWatch

对着背影说爱祢 提交于 2019-12-18 03:04:09
问题 Does anyone know if the HiPerfTimer or the StopWatch class is better for benchmarking, and why? 回答1: Stopwatch is based on High resolution timer (where available), you can check that with IsHighResolution 回答2: They are the same when it comes to high resolution timing. Both use this: [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceCounter(out long PerformanceCount); and this: [DllImport("Kernel32.dll")] private static extern bool QueryPerformanceFrequency(out long

How to use the Swing Timer to delay the loading of a progress bar

自古美人都是妖i 提交于 2019-12-17 22:28:22
问题 I need to find a way to use the Swing Timer with a progress bar. I tried using Thread.sleep(), but it crashed the app when I used it. Any ways to use the Swing Timer instead of the Sleep()? public void piiEros(int dist) { Pii pii = new Pii(); pii.setVisible(true); for(int pc = 0;100 > pc; pc++) { try { Thread.sleep(dist/100); } catch (InterruptedException ex) { Logger.getLogger(Trav.class.getName()).log(Level.SEVERE, null, ex); } pii.pg.setValue(pc); } pii.dispose(); o.Eros(); } NOTES: Pii is

iOS Timer in the background

瘦欲@ 提交于 2019-12-17 22:28:14
问题 I want in my iOS application to start a timer when the app is running in the background and when the app is closed. The timer must check every 30 minutes of there a new notifications. In the timer function they call every 30 minutes another function showNotification(). How do I do this timer and on which place must I call the timer when the app is not running/run in the background. 回答1: It is impossible to do something when the application is not in the foreground, with 100% certainty. You

Create an incrementing timer in seconds in 00:00 format?

梦想与她 提交于 2019-12-17 22:25:34
问题 I want to create an incrementing second timer like a stopwatch. So I want to be able to display the seconds and minutes incrementing in the format 00:01... Google only brings up 24 hour clock examples, I was wondering could anyone get me started with an example or tutorial of what I want to do? Edit: Here is what I have using the Chronometer in Android so far In onCreate() secondsT = 0; elapsedTimeBeforePause = 0; stopWatch.start(); startTime = SystemClock.elapsedRealtime(); stopWatch.setBase