Open In App
Related Articles

PulseCountDown in Android with Example

Like Article
Save Article
Report issue

PulseCountDown in Android is an alternative to CountDownTimer. A CountDownTimer 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 because PulseCountDown provides a default layout with some beautiful animations. By default, the start value of PulseCountDown is 10 and the end value is 0. Suppose there needs a quiz app, and in that add time limit to answer a question there PulseCountDown can be used.  

pulse countdown

Table of Attributes 

XML Attribute



pc_startValuestartValue(int value)Starting value of the PulseCountDown (by default 10)
pc_endValueendValue(int value)Value before which the countdown will stop(by default 0)
start(callback: () -> Unit = {})Start the countdown

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

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 2: Add dependency

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.   

implementation ‘com.gusakov:pulse-countdown:1.1.0-rc1’  

Step 3: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. In this file add the PulseCountDown view and a start button to the layout. Below is the code for the activity_main.xml file. 


        android:text="Start Countdown"
        app:layout_constraintStart_toStartOf="parent" />


Step 4: Working with the MainActivity file

Go to the MainActivity file and refer to the following code. In this file add the onClickListener() method to the button to start the PulseCountDownView. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.


import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.gusakov.library.start
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        // 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 user
                "Course Alert!", Toast.LENGTH_LONG).show()



import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.gusakov.library.PulseCountDown;
public class MainActivity extends AppCompatActivity {
    // creating object of Button and PulseCountDown
    private Button buttonStart;
    private PulseCountDown pulseCountDown;
    protected void onCreate(Bundle savedInstanceState) {
        // initialising objects
        // button OnClickListener
        buttonStart.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // start countdown and add OnCountdownCompleted
                pulseCountDown.start(new OnCountdownCompleted() {
                    public void completed() {
                        // show simple toast when countdown completed
                        Toast.makeText(MainActivity.this, "Pulse Count Completed :)", Toast.LENGTH_SHORT).show();



Last Updated : 07 Nov, 2022
Like Article
Save Article
Share your thoughts in the comments
Similar Reads