OngoingActivityStatus
public
class
OngoingActivityStatus
extends Object
implements
VersionedParcelable,
TimeDependentText
java.lang.Object
|
↳ |
androidx.wear.ongoing.OngoingActivityStatus
|
Base class to serialize / deserialize OngoingActivityStatus
into / from a Notification
A status is composed of Parts, and they are joined together with a template.
Note that for backwards compatibility reasons the code rendering this status message may not
have all of the [StatusPart] classes that are available in later versions of the library.
Templates that do not have values for all of the named parts will not be used.
The template list will be iterated through looking for the first template with all matching named
parts available, this will be selected for rendering the status.
To provide for backwards compatibility, you should provide one (or more) fallback templates which
use status parts from earlier versions of the API. e.g. TextStatusPart & TimerStatusPart
The status and part classes here use timestamps for updating the displayed representation of the
status, in cases when this is needed (chronometers), as returned by
SystemClock.elapsedRealtime()
Summary
Nested classes |
class |
OngoingActivityStatus.Builder
Helper to Build OngoingActivityStatus instances.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
From interface
androidx.wear.ongoing.TimeDependentText
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
forPart
public static OngoingActivityStatus forPart (StatusPart part)
Convenience method for creating a Status with no template and a single Part.
Parameters |
part |
StatusPart : The only Part that composes this status. |
getNextChangeTimeMillis
public long getNextChangeTimeMillis (long fromTimeMillis)
Returns the next time this status could have a different rendering.
There is no guarantee that the rendering will change at the returned time (for example, if
some information in the status is not rendered).
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 next time (counting from fromTimeMillis) that this status may produce a
different result when calling getText().
|
getPart
public StatusPart getPart (String name)
Returns the value of the part with the given name.
Parameters |
name |
String : the name to lookup. |
Returns |
StatusPart |
the part with the given name, can be null.
|
getPartNames
public Set<String> getPartNames ()
Returns |
Set<String> |
the names of the parts provide to this status.
|
getTemplates
public List<CharSequence> getTemplates ()
Returns |
List<CharSequence> |
the list of templates that this status has.
|
getText
public CharSequence getText (Context context,
long timeNowMillis)
Returns a textual representation of this status at the given time. The first template that
has all required information will be used, and each part will be used in their respective
placeholder/s.
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 |
Returns |
CharSequence |
the rendered text, for best compatibility, display using a TextView.
|
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-02-10 UTC.