timer - Do after specific time, Android Runnable -


Ive found an app with a square that implements Runnable where a thread starts and runs () method overrides It runs my graphics.

1. Question: How many times is called ()? I have set a time for it so it should be a default value?

2. Question: I should do stuff after a certain time (2 minutes, 5 minutes, 10 minutes) etc. What would be the best way to do this, I was thinking about using an integer as a counter and once it hits a specific value, what do I want?

1. Question: How many times is the run ()? I have set a time for it, so it should be a default value?

Your thread is called the run () method when you call it for example. yourThread.start ();

2. Question: I should be made after certain time (2 minutes, 5 minutes, 10 minutes) etc. What would be the best way to go about doing this, I was thinking of using an int as a counter and once I assume it is a specific, what do I need?

You can call the thread, sleep () method (NB: Never make it in your UI thread).

Or you can do it as described above, in your run () method you will have a while () loop and on each recurrence Check if the current time difference in last update and milliseconds is greater than the desired period eg. 2 minutes, 5 minutes or 10 minutes.

I hope it will be helpful.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -