Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/FragmentHostCallback#pubctors) \| [Methods](https://developer.android.com/reference/android/app/FragmentHostCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/FragmentHostCallback#inhmethods)

# FragmentHostCallback

*** ** * ** ***

` public abstract class FragmentHostCallback `   
` ` ` extends https://developer.android.com/reference/android/app/FragmentContainer ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.app.FragmentContainer](https://developer.android.com/reference/android/app/FragmentContainer) ||
|   | ↳ | android.app.FragmentHostCallback\<E\> |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 28.**   

Use the [Support Library](https://developer.android.com/tools/extras/support-library) `https://developer.android.com/reference/androidx/fragment/app/FragmentHostCallback.html`

Integration points with the Fragment host.

Fragments may be hosted by any object; such as an `https://developer.android.com/reference/android/app/Activity`. In order to host fragments, implement `https://developer.android.com/reference/android/app/FragmentHostCallback`, overriding the methods applicable to the host.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/FragmentHostCallback#FragmentHostCallback(android.content.Context,%20android.os.Handler,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/os/Handler handler, int windowAnimations) ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onAttachFragment(android.app.Fragment)(https://developer.android.com/reference/android/app/Fragment fragment) ` Called when a `https://developer.android.com/reference/android/app/Fragment` is being attached to this host, immediately after the call to its `https://developer.android.com/reference/android/app/Fragment#onAttach(android.content.Context)` method and before `https://developer.android.com/reference/android/app/Fragment#onCreate(android.os.Bundle)`. |
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onDump(java.lang.String,%20java.io.FileDescriptor,%20java.io.PrintWriter,%20java.lang.String[])(https://developer.android.com/reference/java/lang/String prefix, https://developer.android.com/reference/java/io/FileDescriptor fd, https://developer.android.com/reference/java/io/PrintWriter writer, https://developer.android.com/reference/java/lang/String args) ` Print internal state into the given stream. |
| ` <T extends https://developer.android.com/reference/android/view/View> T` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onFindViewById(int)(int id) ` Return the view with the given resource ID. |
| ` abstract E` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onGetHost()() ` Return the object that's currently hosting the fragment. |
| ` https://developer.android.com/reference/android/view/LayoutInflater` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onGetLayoutInflater()() ` Return a `https://developer.android.com/reference/android/view/LayoutInflater`. |
| ` int` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onGetWindowAnimations()() ` Return the window animations. |
| ` boolean` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onHasView()() ` Return `true` if the container holds any view. |
| ` boolean` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onHasWindowAnimations()() ` Return `true` if there are window animations. |
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onInvalidateOptionsMenu()() ` Invalidates the activity's options menu. |
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onRequestPermissionsFromFragment(android.app.Fragment,%20java.lang.String[],%20int)(https://developer.android.com/reference/android/app/Fragment fragment, https://developer.android.com/reference/java/lang/String permissions, int requestCode) ` Requests permissions from the given fragment. |
| ` boolean` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onShouldSaveFragmentState(android.app.Fragment)(https://developer.android.com/reference/android/app/Fragment fragment) ` Return `true` if the fragment's state needs to be saved. |
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onStartActivityFromFragment(android.app.Fragment,%20android.content.Intent,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Fragment fragment, https://developer.android.com/reference/android/content/Intent intent, int requestCode, https://developer.android.com/reference/android/os/Bundle options) ` Starts a new `https://developer.android.com/reference/android/app/Activity` from the given fragment. |
| ` void` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onStartIntentSenderFromFragment(android.app.Fragment,%20android.content.IntentSender,%20int,%20android.content.Intent,%20int,%20int,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Fragment fragment, https://developer.android.com/reference/android/content/IntentSender intent, int requestCode, https://developer.android.com/reference/android/content/Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, https://developer.android.com/reference/android/os/Bundle options) ` Starts a new `https://developer.android.com/reference/android/content/IntentSender` from the given fragment. |
| ` boolean` | ` https://developer.android.com/reference/android/app/FragmentHostCallback#onUseFragmentManagerInflaterFactory()() ` Return `true` if the FragmentManager's LayoutInflaterFactory should be used. |

### Inherited methods

From class ` https://developer.android.com/reference/android/app/FragmentContainer ` ` abstract <T extends https://developer.android.com/reference/android/view/View> T` ` https://developer.android.com/reference/android/app/FragmentContainer#onFindViewById(int)(int id) `

Return the view with the given resource ID.
` abstract boolean` ` https://developer.android.com/reference/android/app/FragmentContainer#onHasView()() `

Return `true` if the container holds any view.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` 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 https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` 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` ` 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` ` 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 constructors

### FragmentHostCallback

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

```
public FragmentHostCallback (Context context, 
                Handler handler, 
                int windowAnimations)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `handler` | `Handler` <br /> |
| `windowAnimations` | `int` <br /> |

## Public methods

### onAttachFragment

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

```
public void onAttachFragment (Fragment fragment)
```

Called when a `https://developer.android.com/reference/android/app/Fragment` is being attached to this host, immediately after the call to its `https://developer.android.com/reference/android/app/Fragment#onAttach(android.content.Context)` method and before `https://developer.android.com/reference/android/app/Fragment#onCreate(android.os.Bundle)`.

<br />

| Parameters ||
|---|---|
| `fragment` | `Fragment` <br /> |

### onDump

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

```
public void onDump (String prefix, 
                FileDescriptor fd, 
                PrintWriter writer, 
                String[] args)
```

Print internal state into the given stream.

<br />

| Parameters ||
|---|---|
| `prefix` | `String`: Desired prefix to prepend at each line of output. <br /> |
| `fd` | `FileDescriptor`: The raw file descriptor that the dump is being sent to. <br /> |
| `writer` | `PrintWriter`: The PrintWriter to which you should dump your state. This will be closed for you after you return. <br /> |
| `args` | `String`: additional arguments to the dump request. <br /> |

### onFindViewById

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

```
public T onFindViewById (int id)
```

Return the view with the given resource ID. May return `null` if the view is not a child of this container.

<br />

| Parameters ||
|---|---|
| `id` | `int` <br /> |

| Returns ||
|---|---|
| `T` | This value may be `null`. <br /> |

### onGetHost

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

```
public abstract E onGetHost ()
```

Return the object that's currently hosting the fragment. If a `https://developer.android.com/reference/android/app/Fragment` is hosted by a `https://developer.android.com/reference/android/app/Activity`, the object returned here should be the same object returned from `https://developer.android.com/reference/android/app/Fragment#getActivity()`.

<br />

| Returns ||
|---|---|
| `E` | This value may be `null`. <br /> |

### onGetLayoutInflater

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

```
public LayoutInflater onGetLayoutInflater ()
```

Return a `https://developer.android.com/reference/android/view/LayoutInflater`. See `https://developer.android.com/reference/android/app/Activity#getLayoutInflater()`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/LayoutInflater` | <br /> |

### onGetWindowAnimations

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

```
public int onGetWindowAnimations ()
```

Return the window animations.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### onHasView

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

```
public boolean onHasView ()
```

Return `true` if the container holds any view.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### onHasWindowAnimations

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

```
public boolean onHasWindowAnimations ()
```

Return `true` if there are window animations.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### onInvalidateOptionsMenu

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

```
public void onInvalidateOptionsMenu ()
```

Invalidates the activity's options menu. See `https://developer.android.com/reference/android/app/Activity#invalidateOptionsMenu()`

<br />

### onRequestPermissionsFromFragment

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

```
public void onRequestPermissionsFromFragment (Fragment fragment, 
                String[] permissions, 
                int requestCode)
```

Requests permissions from the given fragment. See `https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)`

<br />

| Parameters ||
|---|---|
| `fragment` | `Fragment`: This value cannot be `null`. <br /> |
| `permissions` | `String`: This value cannot be `null`. <br /> |
| `requestCode` | `int` <br /> |

### onShouldSaveFragmentState

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

```
public boolean onShouldSaveFragmentState (Fragment fragment)
```

Return `true` if the fragment's state needs to be saved.

<br />

| Parameters ||
|---|---|
| `fragment` | `Fragment` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### onStartActivityFromFragment

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

```
public void onStartActivityFromFragment (Fragment fragment, 
                Intent intent, 
                int requestCode, 
                Bundle options)
```

Starts a new `https://developer.android.com/reference/android/app/Activity` from the given fragment. See `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)`.

<br />

| Parameters ||
|---|---|
| `fragment` | `Fragment` <br /> |
| `intent` | `Intent` <br /> |
| `requestCode` | `int` <br /> |
| `options` | `Bundle` <br /> |

### onStartIntentSenderFromFragment

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

```
public void onStartIntentSenderFromFragment (Fragment fragment, 
                IntentSender intent, 
                int requestCode, 
                Intent fillInIntent, 
                int flagsMask, 
                int flagsValues, 
                int extraFlags, 
                Bundle options)
```

Starts a new `https://developer.android.com/reference/android/content/IntentSender` from the given fragment. See `https://developer.android.com/reference/android/app/Activity#startIntentSender(android.content.IntentSender,%20android.content.Intent,%20int,%20int,%20int,%20android.os.Bundle)`.

<br />

| Parameters ||
|---|---|
| `fragment` | `Fragment` <br /> |
| `intent` | `IntentSender` <br /> |
| `requestCode` | `int` <br /> |
| `fillInIntent` | `Intent`: This value may be `null`. <br /> |
| `flagsMask` | `int` <br /> |
| `flagsValues` | `int` <br /> |
| `extraFlags` | `int` <br /> |
| `options` | `Bundle` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/content/IntentSender.SendIntentException` |   |

### onUseFragmentManagerInflaterFactory

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

```
public boolean onUseFragmentManagerInflaterFactory ()
```

Return `true` if the FragmentManager's LayoutInflaterFactory should be used.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |