Stay organized with collections
Save and categorize content based on your preferences.
SliceMetrics
public
class
SliceMetrics
extends Object
This class was deprecated
in API level 35.
Slice framework has been deprecated, it will not receive any updates from
ERROR(/android.os.Build.VANILLA_ICE_CREAM)
and forward. If you are looking for a
framework that sends displayable data from one app to another, consider using
AppSearchManager
.
Metrics interface for slices.
This is called by SliceView, so Slice developers should
not need to reference this class.
Summary
Public constructors |
SliceMetrics(Context context, Uri uri)
An object to be used throughout the life of a slice to register events.
|
Public methods |
void
|
logHidden()
To be called whenever the slice becomes invisible to the user.
|
void
|
logTouch(int actionType, Uri subSlice)
To be called whenever the user invokes a discrete action via a slice.
|
void
|
logVisible()
To be called whenever the slice becomes visible to the user.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public constructors
SliceMetrics
public SliceMetrics (Context context,
Uri uri)
An object to be used throughout the life of a slice to register events.
Parameters |
context |
Context : This value cannot be null . |
uri |
Uri : This value cannot be null . |
Public methods
logHidden
public void logHidden ()
To be called whenever the slice becomes invisible to the user.
logTouch
public void logTouch (int actionType,
Uri subSlice)
To be called whenever the user invokes a discrete action via a slice.
Use this for discrete events like a tap or the end of a drag,
not for a continuous streams of events, such as the motion during a gesture.
Parameters |
actionType |
int : The type of the event. |
subSlice |
Uri : The URI of the sub-slice that is the subject of the interaction.
This value cannot be null . |
logVisible
public void logVisible ()
To be called whenever the slice becomes visible to the user.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-04-17 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-04-17 UTC."],[],[],null,["# SliceMetrics\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nDeprecated in [API level\n35](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Ctors](#pubctors) \\| [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nSliceMetrics\n============\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/app/slice/SliceMetrics \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\nclass\nSliceMetrics\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|--------------------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | android.app.slice.SliceMetrics |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\n**This class was deprecated\nin API level 35.** \n\nSlice framework has been deprecated, it will not receive any updates from\n[ERROR(/android.os.Build.VANILLA_ICE_CREAM)](/) and forward. If you are looking for a\nframework that sends displayable data from one app to another, consider using\n[AppSearchManager](/reference/android/app/appsearch/AppSearchManager).\n\nMetrics interface for slices.\n\nThis is called by SliceView, so Slice developers should\nnot need to reference this class. \n**See also:**\n\n- [ERROR(/androidx.slice.widget.SliceView)](/)\n\nSummary\n-------\n\n| ### Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[SliceMetrics](/reference/android/app/slice/SliceMetrics#SliceMetrics(android.content.Context,%20android.net.Uri))`(`[Context](/reference/android/content/Context)` context, `[Uri](/reference/android/net/Uri)` uri) ` An object to be used throughout the life of a slice to register events. |\n\n| ### Public methods ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[logHidden](/reference/android/app/slice/SliceMetrics#logHidden())`() ` To be called whenever the slice becomes invisible to the user. |\n| ` void` | ` `[logTouch](/reference/android/app/slice/SliceMetrics#logTouch(int,%20android.net.Uri))`(int actionType, `[Uri](/reference/android/net/Uri)` subSlice) ` To be called whenever the user invokes a discrete action via a slice. |\n| ` void` | ` `[logVisible](/reference/android/app/slice/SliceMetrics#logVisible())`() ` To be called whenever the slice becomes visible to the user. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nPublic constructors\n-------------------\n\n### SliceMetrics\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic SliceMetrics (Context context, \n Uri uri)\n```\n\nAn object to be used throughout the life of a slice to register events.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------------------------------------|\n| `context` | `Context`: This value cannot be `null`. \u003cbr /\u003e |\n| `uri` | `Uri`: This value cannot be `null`. \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### logHidden\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void logHidden ()\n```\n\nTo be called whenever the slice becomes invisible to the user.\n\n\u003cbr /\u003e\n\n### logTouch\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void logTouch (int actionType, \n Uri subSlice)\n```\n\nTo be called whenever the user invokes a discrete action via a slice.\n\n\nUse this for discrete events like a tap or the end of a drag,\nnot for a continuous streams of events, such as the motion during a gesture.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|-------------------------------------------------------------------------------------------------------------|\n| `actionType` | `int`: The type of the event. \u003cbr /\u003e |\n| `subSlice` | `Uri`: The URI of the sub-slice that is the subject of the interaction. This value cannot be `null`. \u003cbr /\u003e |\n\n**See also:**\n\n- [ERROR(/androidx.slice.widget.EventInfo#actionType)](/) \n\n### logVisible\n\nAdded in [API level 28](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic void logVisible ()\n```\n\nTo be called whenever the slice becomes visible to the user.\n\n\u003cbr /\u003e"]]