# ChooserManager

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Summary:[Methods](https://developer.android.com/reference/android/service/chooser/ChooserManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/service/chooser/ChooserManager#inhmethods)  

# ChooserManager

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/service/chooser/ChooserManager "View this page in Kotlin")\|Java

`
public


class
ChooserManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.service.chooser.ChooserManager |

<br />

*** ** * ** ***

Manages the creation, tracking, and retrieval of chooser sessions.

An Interactive Chooser Session allows apps to invoke the system Chooser without entirely covering app UI. Users may interact with both the app and Chooser, while bidirectional communication between the two ensures a consistent state.

### Usage Example:

    ChooserManager chooserManager = context.getSystemService(ChooserManager.class);
     if (chooserManager == null) {
         // handle the case when the interactive chooser session functionality is not supported.
     }

     // Construct the sharing intent
     Intent targetIntent = new Intent(Intent.ACTION_SEND);
     targetIntent.setType("text/plain");
     targetIntent.putExtra(Intent.EXTRA_TEXT, "This is a message that will be shared.");

     Intent chooserIntent = Intent.createChooser(targetIntent, null);

     // Start a new chooser session
     ChooserSession session = chooserManager.startSession(context, chooserIntent);
     ChooserSessionToken token = session.getToken();
     // Optionally, store the token int an activity saved state to re-associate with the session later

     // Later, to retrieve a session using a token:
     ChooserSessionToken retrievedToken = ... // obtain the stored token
     ChooserSession existingSession = chooserManager.getSession(retrievedToken);
     if (existingSession != null) {
     // Interact with the existing session
     }
     
<br />

**See also:**

- [ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession)
- [ChooserSessionToken](https://developer.android.com/reference/android/service/chooser/ChooserSessionToken)

## Summary

|                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                       ||
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession) | ` `[getSession](https://developer.android.com/reference/android/service/chooser/ChooserManager#getSession(android.service.chooser.ChooserSessionToken))`(`[ChooserSessionToken](https://developer.android.com/reference/android/service/chooser/ChooserSessionToken)` token) ` Returns a[ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession)associated with this token or`null`if there is no active session. |
| ` `[ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession) | ` `[startSession](https://developer.android.com/reference/android/service/chooser/ChooserManager#startSession(android.content.Context,%20android.content.Intent))`(`[Context](https://developer.android.com/reference/android/content/Context)` context, `[Intent](https://developer.android.com/reference/android/content/Intent)` chooserIntent) ` Starts a new interactive Chooser session.                                                            |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/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](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/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](https://developer.android.com/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](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### getSession

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public ChooserSession getSession (ChooserSessionToken token)
```

Returns a[ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession)associated with this token or`null`if there is no active session.

<br />

|                                                                                  Parameters                                                                                   ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `token` | `ChooserSessionToken`:[ChooserSessionToken](https://developer.android.com/reference/android/service/chooser/ChooserSessionToken). This value cannot be`null`. <br /> |

|                                                 Returns                                                  ||
|--------------------------------------------------------------------------------------------------|--------|
| [ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession) | <br /> |

**See also:**

- [ChooserSession.getToken()](https://developer.android.com/reference/android/service/chooser/ChooserSession#getToken())  

### startSession

Added in[version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  

```
public ChooserSession startSession (Context context, 
                Intent chooserIntent)
```

Starts a new interactive Chooser session. The method is idempotent and will start Chooser only once.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`       | `Context`: This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `chooserIntent` | `Intent`: an[Intent.ACTION_CHOOSER](https://developer.android.com/reference/android/content/Intent#ACTION_CHOOSER)intent that will be used as a base for the new Chooser session. An interactive Chooser session also supports the following chooser parameters: - [Intent.EXTRA_ALTERNATE_INTENTS](https://developer.android.com/reference/android/content/Intent#EXTRA_ALTERNATE_INTENTS) - [Intent.EXTRA_INITIAL_INTENTS](https://developer.android.com/reference/android/content/Intent#EXTRA_INITIAL_INTENTS) - [Intent.EXTRA_EXCLUDE_COMPONENTS](https://developer.android.com/reference/android/content/Intent#EXTRA_EXCLUDE_COMPONENTS) - [Intent.EXTRA_REPLACEMENT_EXTRAS](https://developer.android.com/reference/android/content/Intent#EXTRA_REPLACEMENT_EXTRAS) - [Intent.EXTRA_CHOOSER_TARGETS](https://developer.android.com/reference/android/content/Intent#EXTRA_CHOOSER_TARGETS) - [Intent.EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER](https://developer.android.com/reference/android/content/Intent#EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER) - [Intent.EXTRA_CHOOSER_RESULT_INTENT_SENDER](https://developer.android.com/reference/android/content/Intent#EXTRA_CHOOSER_RESULT_INTENT_SENDER) - [Intent.EXTRA_CHOSEN_COMPONENT_INTENT_SENDER](https://developer.android.com/reference/android/content/Intent#EXTRA_CHOSEN_COMPONENT_INTENT_SENDER) <br /> See also[Intent.createChooser(Intent, CharSequence)](https://developer.android.com/reference/android/content/Intent#createChooser(android.content.Intent,%20java.lang.CharSequence)). This value cannot be`null`. <br /> |

|                                                               Returns                                                                ||
|--------------------------------------------------------------------------------------------------|------------------------------------|
| [ChooserSession](https://developer.android.com/reference/android/service/chooser/ChooserSession) | This value cannot be`null`. <br /> |