I am writing a app for which i need to display the Time elapsed when user presses a button in UI screen .
So please guide me in writing the code in Android. I need to display the time in seconds, mins and hours.
Thanks in anticipation.
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 can get the current system time in milliseconds by calling
System.currentTimeMillis(). You can store this in an variable on Activity start and then calculate the difference between the current time and the stored time in theonClickmethod of the button.example: