# ActionMode.Callback2

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Callback2

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/view/ActionMode.Callback2 "View this page in Java")  

```
abstract class Callback2 : ActionMode.Callback
```

|---|------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                         ||
| ↳ | [android.view.ActionMode.Callback2](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback2#) |

Extension of[ActionMode.Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback)to provide content rect information. This is required for ActionModes with dynamic positioning such as the ones with type[ActionMode.TYPE_FLOATING](https://developer.android.com/reference/kotlin/android/view/ActionMode#TYPE_FLOATING:kotlin.Int)to ensure the positioning doesn't obscure app content. If an app fails to provide a subclass of this class, a default implementation will be used.

## Summary

|                                                   Public constructors                                                   ||
|----------------------------------------------------------------------------------------------------------------------|---|
| [Callback2](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback2#Callback2())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                              Public methods                                                                                                                                                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onGetContentRect](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback2#onGetContentRect(android.view.ActionMode,%20android.view.View,%20android.graphics.Rect))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`, `view:` `[View](https://developer.android.com/reference/kotlin/android/view/View)!`, `outRect:` `[Rect](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#)!`)` Called when an ActionMode needs to be positioned on screen, potentially occluding view content. |

| Inherited functions ||
|---|---|
| From class[Callback](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback) |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onActionItemClicked](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback#onActionItemClicked(android.view.ActionMode,%20android.view.MenuItem))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`, `item:` `[MenuItem](https://developer.android.com/reference/kotlin/android/view/MenuItem)!`)` <br /> Called to report a user click on an action button. <br />                                                         | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onCreateActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback#onCreateActionMode(android.view.ActionMode,%20android.view.Menu))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)!`)` <br /> Called when action mode is first created. The menu supplied will be used to generate action buttons for the action mode. <br /> | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)       | [onDestroyActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback#onDestroyActionMode(android.view.ActionMode))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`)` <br /> Called when an action mode is about to be exited and destroyed. <br />                                                                                                                                                                  | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onPrepareActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode.Callback#onPrepareActionMode(android.view.ActionMode,%20android.view.Menu))`(`mode:` `[ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!`, `menu:` `[Menu](https://developer.android.com/reference/kotlin/android/view/Menu)!`)` <br /> Called to refresh an action mode's action menu whenever it is invalidated. <br />                                             | ||

## Public constructors

### Callback2

```
Callback2()
```

## Public methods

### onGetContentRect

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onGetContentRect(
    mode: ActionMode!, 
    view: View!, 
    outRect: Rect!
): Unit
```

Called when an ActionMode needs to be positioned on screen, potentially occluding view content. Note this may be called on a per-frame basis.

|                                                                                                                                                         Parameters                                                                                                                                                         ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mode`    | [ActionMode](https://developer.android.com/reference/kotlin/android/view/ActionMode)!:The ActionMode that requires positioning.                                                                                                                                                                                 |
| `view`    | [View](https://developer.android.com/reference/kotlin/android/view/View)!:The View that originated the ActionMode, in whose coordinates the Rect should be provided.                                                                                                                                            |
| `outRect` | [Rect](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#)!:The Rect to be populated with the content position. Use this to specify where the content in your app lives within the given view. This will be used to avoid occluding the given content Rect with the created ActionMode. |