phedon rousou
phedon rousou

Reputation: 1780

Android: time listener

Is there a time listener in Android? I have a service that implements a location Listener. When there is no GPS lock, eg in a subway, I would like to send a notification based on time.

eg. If the train arrives at station A at 12:30. If the current clock is 12:30, I would like to send a notification to the user.

The problem is that I didn't find anywhere a method for "onTimeChanged". Is there any way to achieve that? I know about the System.currentTimeMillis()) but where do I put it to check every second?

Upvotes: 2

Views: 3187

Answers (2)

Pravin Kale
Pravin Kale

Reputation: 63

You can use TimerTask class http://developer.android.com/reference/java/util/TimerTask.html which would help you to schedule new Task after some time interval.

Upvotes: 1

Sébastien
Sébastien

Reputation: 14831

You'll be able to achieve this using AlarmManager

This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running.

Upvotes: 1

Related Questions