Skip to content

Most visited

Recently visited

navigation

ComplicationText

public class ComplicationText
extends Object implements Parcelable

java.lang.Object
   ↳ android.support.wearable.complications.ComplicationText


Represents a piece of text to be shown in a complication.

ComplicationText can be a plain string or it can contain a time-dependent value, for which the value varies depending on the current date/time.

Instances of this class should be obtained either by calling plainText(CharSequence), or by using one of the provided builders: ComplicationText.TimeDifferenceBuilder or ComplicationText.TimeFormatBuilder.

Summary

Nested classes

class ComplicationText.TimeDifferenceBuilder

Builder for a ComplicationText object that displays a text representation of the difference between the given time and the specified time period, within a surrounding string if required. 

@interface ComplicationText.TimeDifferenceStyle

 

class ComplicationText.TimeFormatBuilder

Builder for a ComplicationText object that displays a text representation of the given time, using the provided format and time zone, within a surrounding string if specified. 

@interface ComplicationText.TimeFormatStyle

 

Constants

int DIFFERENCE_STYLE_SHORT_DUAL_UNIT

Style for time differences shown in a short alpha-numeric style, with up to two significant units included.

int DIFFERENCE_STYLE_SHORT_SINGLE_UNIT

Style for time differences shown in a short alpha-numeric style, with only the most significant unit included.

int DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT

Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included, that should fit within the character limit for a short text field.

int DIFFERENCE_STYLE_STOPWATCH

Style for time differences shown in a numeric fashion like a timer.

int DIFFERENCE_STYLE_WORDS_SINGLE_UNIT

Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included.

int FORMAT_STYLE_DEFAULT

Style where the formatted date/time should be shown unchanged.

int FORMAT_STYLE_LOWER_CASE

Style where the formatted date/time should be shown in lower case.

int FORMAT_STYLE_UPPER_CASE

Style where the formatted date/time should be capitalized.

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ComplicationText> CREATOR

Public methods

int describeContents()
CharSequence getText(Context context, long dateTimeMillis)

Returns the text that should be displayed for the given time.

static CharSequence getText(Context context, ComplicationText complicationText, long dateTimeMillis)

Returns complicationText.getText(dateTimeMillis, res) if complicationText is not null, or null otherwise.

static ComplicationText plainText(CharSequence text)

Returns a ComplicationText object that will display the given text for any input time.

void writeToParcel(Parcel out, int flags)

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

DIFFERENCE_STYLE_SHORT_DUAL_UNIT

int DIFFERENCE_STYLE_SHORT_DUAL_UNIT

Style for time differences shown in a short alpha-numeric style, with up to two significant units included.

For time difference t:

If t < 1 hour, the value will be shown as a number of minutes, such as 2m for 2 minutes. Seconds are not displayed.

If 1 hour <= t < 1 day, the value will be shown as hours and minutes, such as 4h 2m for 4 hours and 2 minutes.

If 1 day <= t < 10 days, the value will be shown as days and hours, such as 3d 4h for 3 days 4 hours.

If 10 days <= t, the value will be shown as a number of days, such as 13d for 13 days.

The characters used will be localised to match the default locale. If the representation of the time difference with two units would be too long in the default locale, just a single unit may be shown instead.

Constant Value: 3 (0x00000003)

DIFFERENCE_STYLE_SHORT_SINGLE_UNIT

int DIFFERENCE_STYLE_SHORT_SINGLE_UNIT

Style for time differences shown in a short alpha-numeric style, with only the most significant unit included.

For time difference t:

If t < 1 hour, the value will be shown as a number of minutes, such as 2m for 2 minutes. Seconds are not displayed.

If 1 hour <= t < 1 day, the value will be shown as a number of hours, such as 4h for 4 hours.

If 1 days <= t, the value will be shown as a number of days, such as 13d for 13 days.

The characters used will be localised to match the default locale.

Constant Value: 2 (0x00000002)

DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT

int DIFFERENCE_STYLE_SHORT_WORDS_SINGLE_UNIT

Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included, that should fit within the character limit for a short text field.

The output will be the same as for DIFFERENCE_STYLE_WORDS_SINGLE_UNIT, except that if the text does not fit into the seven character limit then a shorter form will be used instead, e.g. "1356d" instead of "1356 days".

Constant Value: 5 (0x00000005)

DIFFERENCE_STYLE_STOPWATCH

int DIFFERENCE_STYLE_STOPWATCH

Style for time differences shown in a numeric fashion like a timer.

For time difference t:

If t < 1 hour, the value will be shown as minutes and seconds, such as 02:35 for 2 minutes and 35 seconds.

If 1 hour <= t < 1 day, the value will be shown as hours and minutes, such as 4:02 for 4 hours and 2 minutes, or as 12:02 for 12 hours and 2 minutes.

If 1 day <= t < 10 days, the value will be shown as days and hours, such as 3d 4h for 3 days 4 hours.

If 10 days <= t, the value will be shown as just days, such as 13d for 13 days.

The characters used will be localised to match the default locale.

Constant Value: 1 (0x00000001)

DIFFERENCE_STYLE_WORDS_SINGLE_UNIT

int DIFFERENCE_STYLE_WORDS_SINGLE_UNIT

Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included.

For time difference t:

If t < 1 hour, the value will be shown as a number of minutes, such as 1 min for 1 minute or 2 mins for 2 minutes. Seconds are not displayed.

If 1 hour <= t < 1 day, the value will be shown as a number of hours, such as 1 hour for 1 hour or 4 hours for 4 hours.

If 1 days <= t, the value will be shown as a number of days, such as 1 day for 1 day or 13 days for 13 days.

The words used will be localised to match the default locale.

Constant Value: 4 (0x00000004)

FORMAT_STYLE_DEFAULT

int FORMAT_STYLE_DEFAULT

Style where the formatted date/time should be shown unchanged.

Constant Value: 1 (0x00000001)

FORMAT_STYLE_LOWER_CASE

int FORMAT_STYLE_LOWER_CASE

Style where the formatted date/time should be shown in lower case.

Constant Value: 3 (0x00000003)

FORMAT_STYLE_UPPER_CASE

int FORMAT_STYLE_UPPER_CASE

Style where the formatted date/time should be capitalized.

Constant Value: 2 (0x00000002)

Fields

CREATOR

Creator<ComplicationText> CREATOR

Public methods

describeContents

int describeContents ()

Returns
int

getText

CharSequence getText (Context context, 
                long dateTimeMillis)

Returns the text that should be displayed for the given time.

Parameters
context Context

dateTimeMillis long

Returns
CharSequence

getText

CharSequence getText (Context context, 
                ComplicationText complicationText, 
                long dateTimeMillis)

Returns complicationText.getText(dateTimeMillis, res) if complicationText is not null, or null otherwise.

Parameters
context Context

complicationText ComplicationText

dateTimeMillis long

Returns
CharSequence

plainText

ComplicationText plainText (CharSequence text)

Returns a ComplicationText object that will display the given text for any input time.

Parameters
text CharSequence: the text to be displayed

Returns
ComplicationText

writeToParcel

void writeToParcel (Parcel out, 
                int flags)

Parameters
out Parcel

flags int

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)