PulseCountDown in Android is an alternative to CountDownTimer. A countdown timer is an accurate timer that can be used for a website or blog to display the count down to any special event, such as a birthday or anniversary. It is very easy to implement PulseCountDown instead of CountDownTimer beacuse PulseCountDown provides a default layout with some beatiful animations. By default start value of PulseCountDown is 10 and end value is 0. Suppose there need an quiz app, and in that add time limit to answer a question there PulseCountDown can be used.

Table of Attributes
| XML Attribute | Method | Functionality |
| pc_startValue | startValue(int value) | starting value of the PulseCountDown( by default 10) |
| pc_endValue | endValue(int value) | value before which the countdown will stopped(by default 0) |
| – | start(callback: () -> Unit = {}) | start the countdown |
Approach
Note: Minimum SDK version must be more than API 22: Android 5.1 (Lollipop) to implement this dependency. So choose the appropriate SDK while creating the new project.
- Step 1: Add the support Library in build.gradle file and add dependency in the dependencies section.
implementation 'com.gusakov:pulse-countdown:1.1.0-rc1'chevron_rightfilter_none - Step 2: Add the following code in activity_main.xml file. In this file add the PulseCountDown view and a start button to the layout.
activity_main.xml
<androidx.constraintlayout.widget.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><com.gusakov.library.PulseCountDownandroid:id="@+id/pulseCountDown"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="5"android:textSize="100sp"app:pc_startValue="5"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent"/><Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="188dp"android:text="Start Countdown"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"/></androidx.constraintlayout.widget.ConstraintLayout>chevron_rightfilter_none - Step 3: Add the following code in MainActivity.kt file. In this file add
onClickListner()method to the button to start the PulseCountDownView.
MainActivity.kt
packageorg.geeksforgeeks.pulsecountdownimportandroidx.appcompat.app.AppCompatActivityimportandroid.os.Bundleimportandroid.view.Viewimportandroid.widget.Toastimportcom.gusakov.library.startimportkotlinx.android.synthetic.main.activity_main.*classMainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)// when the user tap on the button this// function get invoked automatically.button.setOnClickListener(View.OnClickListener {pulseCountDown.start {// when countdown ends a toast// will be shown to userToast.makeText(this,"Course Alert!", Toast.LENGTH_LONG).show()}})}}chevron_rightfilter_none - Android | Android Application File Structure
- Android | AdMob Interstitial Ads for Android Studio
- Android | How to Create/Start a New Project in Android Studio?
- Android | Running your first Android app
- Android | How to add Radio Buttons in an Android Application?
- Android | How to Request permissions in Android Application?
- Difference between Android 1.1 and Android 4.0.1
- Difference between Android 1.1 and Android 2.3.4
- Difference between Android 1.0 and Android 1.1
- Difference between Android 1.0 and Android 7.1
- Difference between Android 1.0 and Android 2.3
- Difference between Android 1.0 and Android 2.2
- Difference between Android 1.0 and Android 1.6
- Difference between Android 1.0 and Android 2.1
- Difference between Android 1.0 and Android 2.0.1
- Difference between Android 1.0 and Android 2.0
- Difference between Android 1.0 and Android 1.5
- Difference between Android 1.0 and Android 2.3.3
- Difference between Android 1.0 and Android 4.2.1
- Difference between Android 1.0 and Android 2.3.7
Output: Run on Emulator
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

