20 C
Alba Iulia
Wednesday, June 3, 2020

Chronometer Tutorial With Example In Android Studio

Must Read

Android Chat App using Firebase Tutorial

रायपुर। अंधविश्वास का एक और मामला छत्तीसगढ़ के जसपुर में देखने में आया है। यहाँ बिजली गिरने...

Setting Up Android Project Chat App using Firebase

नई दिल्ली। राहुल गांधी ने अंतरराष्ट्रीय ख्याति प्राप्त अर्थशास्त्री और भारतीय रिज़र्व बैंक के पूर्व गवर्नर रघुराज...

Firebase Database data into Recyclerview

घोषित तौर पर भले ही कुछ न हो लेकिन देश भर में लॉकडाउन के बाद से ही...
24,841FansLike
451FollowersFollow
1FollowersFollow
58,945FollowersFollow
0FollowersFollow
505FollowersFollow
0SubscribersSubscribe

In Android, Chronometer is a class that implements a simple timer. Chronometer is a subclass of TextView. This class helps us to add a timer in our app.

You can give Timer start time in the elapsedRealTime() timebase and it start counting from that. If we don’t give base time then it will use the time at which time we call start() method. By default a chronometer displays the current timer value in the form of MM:SS or H:MM:SS. We can set our own format into an arbitrary string.

Chronometer Use Case.

Donate to SyncSaS Independent journalism that speaks truth to power and is free of corporate and political control is possible only when people start contributing towards the same. Please consider donating towards this endeavour to fight fake news and misinformation.
Donate Now
To make an instant donation, click on the "Donate Now" button above. For information regarding donation via Bank Transfer/Cheque/DD, click here.
  • Display digital time text with default format like mm:ss. This is commonly use case.
  • Display a count down timer.
  • Display what ever text that you want to display every second.
  • Display different images every second.

By default, chronometer counts upwards. If you want to have countdown chronometer, you need to call setCountDown method passing true as value to it. This feature is useful to count down from future time. Let’s say you want to count down from tomorrow in your app. Then you need to first set setCountDown to true and set base to SystemClock.elapsedRealtime() + one day’s time in milliseconds which is 10006060*24.

Chronometer can be started by calling start method. Before chronometer is started, you need to set starting point of time from that you want chronometer to start the count, by using setBase method and passing starting point of time. By default, meaning if you don’t set base, it starts counting from 0 because Chronometer’s default base time is time at which start method is called.

ChronoMeter is a widget that are used as simple timer. You can give it a start time and it will start counting up from there, or if you don’t provide a base time, it will use the time at which you will call start() method. The timer also counts down from a base time. If you want to count down, you need to call setCountDown(boolean) method with true value.

Latest News

Android Chat App using Firebase Tutorial

रायपुर। अंधविश्वास का एक और मामला छत्तीसगढ़ के जसपुर में देखने में आया है। यहाँ बिजली गिरने...

Setting Up Android Project Chat App using Firebase

नई दिल्ली। राहुल गांधी ने अंतरराष्ट्रीय ख्याति प्राप्त अर्थशास्त्री और भारतीय रिज़र्व बैंक के पूर्व गवर्नर रघुराज राजन से बात की है।...

Firebase Database data into Recyclerview

घोषित तौर पर भले ही कुछ न हो लेकिन देश भर में लॉकडाउन के बाद से ही बुनियादी स्वास्थ्य सुविधाएं निलंबित चल...

Building Android Apps React Native Tutorial

We live in the world of a variety of mobile devices majorly dominated by two platforms, iOS, and Android. It is a...

Firebase Analytics Dashboard for Android App

प्योंगयांग। क्या नॉर्थ कोरिया के तानाशाह किम जोंग उंग की हालत बहुत गंभीर है? क्या उनके बाद देश संभालने के लिए किसी...
- Advertisement -

SyncSaS
Technologies

Install SyncSaS Android App