Android 12 Developer Preview is here! Try it out, and give us your feedback!

TimeDependentText

public interface TimeDependentText

androidx.wear.ongoing.TimeDependentText


Represents the status or a part of the status of an ongoing activity. Its content may change with time (for example, if the status contains a timer)

Summary

Public methods

abstract long getNextChangeTimeMillis(long fromTimeMillis)

Returns the timestamp of the next time when the display may be different from the one at the specified time.

abstract CharSequence getText(Context context, long timeNowMillis)

Returns a textual representation of the ongoing activity status or a part of it at the given time represented as milliseconds timestamp For forward compatibility, the best way to display this is on a TextView

Public methods

getNextChangeTimeMillis

public abstract long getNextChangeTimeMillis (long fromTimeMillis)

Returns the timestamp of the next time when the display may be different from the one at the specified time.

Parameters
fromTimeMillis long: current time, usually now as returned by SystemClock.elapsedRealtime(). In most cases getText and getNextChangeTimeMillis should be called with the exact same timestamp, so changes are not missed.

Returns
long the first point in time after fromTimeMillis when the displayed value of this status may change. returns Long.MAX_VALUE if the display will never change.

getText

public abstract CharSequence getText (Context context, 
                long timeNowMillis)

Returns a textual representation of the ongoing activity status or a part of it at the given time represented as milliseconds timestamp For forward compatibility, the best way to display this is on a TextView

Parameters
context Context: may be used for internationalization. Only used while this method executed.

timeNowMillis long: the timestamp of the time we want to display, usually now, as returned by SystemClock.elapsedRealtime().

Returns
CharSequence