How to use Intent.ACTION_TIME_TICK

In one of my applications, it was required to update a TextView every minute. The first approach that I could think of was to have an AsyncTask running a while loop till a minute (check for initial time+60,000 milliseconds in every iteration), but then I found out about ACTION_TIME_TICK broadcast action.

As per java docs:-

public static final String ACTION_TIME_TICK

Broadcast Action: The current time has changed. Sent every minute. You cannot receive this through components declared in manifests, only by explicitly registering for it with Context.registerReceiver().

This is a protected intent that can only be sent by the system.

Note: It is assumed that reader has knowledge of how to create and run a simple android application.

Continue reading “How to use Intent.ACTION_TIME_TICK”