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-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SliceMetrics\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSliceMetrics\n============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/slice/SliceMetrics \"View this page in Java\") \n\n```\nopen class SliceMetrics\n```\n\n|---|-------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.slice.SliceMetrics](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 35.**\n|\n| Slice framework has been deprecated, it will not receive any updates from 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 [android.app.appsearch.AppSearchManager](../appsearch/AppSearchManager.html#).\n\nMetrics interface for slices. This is called by SliceView, so Slice developers should not need to reference this class.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [SliceMetrics](#SliceMetrics(android.content.Context,%20android.net.Uri))`(`context:` `[Context](../../content/Context.html#)`, `uri:` `[Uri](../../net/Uri.html#)`)` An object to be used throughout the life of a slice to register events. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [logHidden](#logHidden())`()` To be called whenever the slice becomes invisible to the user. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [logTouch](#logTouch(kotlin.Int,%20android.net.Uri))`(`actionType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `subSlice:` `[Uri](../../net/Uri.html#)`)` To be called whenever the user invokes a discrete action via a slice. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [logVisible](#logVisible())`()` To be called whenever the slice becomes visible to the user. |\n\nPublic constructors\n-------------------\n\n### SliceMetrics\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nSliceMetrics(\n context: Context, \n uri: Uri)\n```\n\nAn object to be used throughout the life of a slice to register events.\n\n| Parameters ||\n|-----------|----------------------------------------------------------------------|\n| `context` | [Context](../../content/Context.html#): This value cannot be `null`. |\n| `uri` | [Uri](../../net/Uri.html#): This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### logHidden\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun logHidden(): Unit\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nTo be called whenever the slice becomes invisible to the user. \n\n### logTouch\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun logTouch(\n actionType: Int, \n subSlice: Uri\n): Unit\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nTo be called whenever the user invokes a discrete action via a slice.\n\nUse 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.\n\n| Parameters ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------|\n| `actionType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The type of the event. |\n| `subSlice` | [Uri](../../net/Uri.html#): The URI of the sub-slice that is the subject of the interaction. This value cannot be `null`. |\n\n**See Also**\n\n### logVisible\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun logVisible(): Unit\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nTo be called whenever the slice becomes visible to the user."]]