Hi I got a service in android and I want it to update something every 10 seconds. So I was thinking of having a wait and then restart the function (cant think of what to call it). Any ideas on how to do a wait in a service?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will want to use threading. This can be done with something like this.
You can then call
thread.sleep(10000). The 10000 translates to 10 seconds.If you look at the accepted answer on this post the posters code shows all of this in an excellent way to understand.
Old SO Post