Alex
Alex

Reputation: 1

Android Chronometer: setUsesChronometer

I am making a basic notification app and just want to integrate a chronometer to it. I have the basic notification ready.

How to add chronometer using: setUsesChronometer();

And also how do I use setVibrate() method for the same?

Upvotes: 0

Views: 1686

Answers (1)

Shadab Ansari
Shadab Ansari

Reputation: 7070

Wherever you are creating your notification, you add below lines to add Chronometer data to your notification.

        long elapsedTime = SystemClock.elapsedRealtime() - mChronometer.getBase();
        notification.setWhen(System.currentTimeMillis()- elapsedTime);

        notification.setUsesChronometer(true);

For vibration, you need to define the vibration pattern -

.setVibrate(new long[]{500,1000}) //vibrates at 5000 ms and 1 second.

Upvotes: 1

Related Questions