# ActivityKt

Added in 2.4.0

*** ** * ** ***


```
public final class ActivityKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/ActivityKt#(androidx.appcompat.app.AppCompatActivity).setupActionBarWithNavController(androidx.navigation.NavController,androidx.navigation.ui.AppBarConfiguration)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration )` Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |
| `static final void` | `https://developer.android.com/reference/androidx/navigation/ui/ActivityKt#(androidx.appcompat.app.AppCompatActivity).setupActionBarWithNavController(androidx.navigation.NavController,androidx.drawerlayout.widget.DrawerLayout)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController, https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout )` Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`. |

## Public methods

### setupActionBarWithNavController

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/Activity.kt+function:setupActionBarWithNavController) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public static final void setupActionBarWithNavController(
    @NonNull AppCompatActivity receiver,
    @NonNull NavController navController,
    @NonNull AppBarConfiguration configuration
)
```

Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The `https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration` you provide controls how the Navigation button is displayed.

You are responsible for calling `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` to handle the Navigation button. Typically this is done in `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#onSupportNavigateUp()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the action bar. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/ui/AppBarConfiguration configuration` | Additional configuration options for customizing the behavior of the ActionBar |

### setupActionBarWithNavController

Artifact: [androidx.navigation:navigation-ui](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/ui/Activity.kt+function:setupActionBarWithNavController) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public static final void setupActionBarWithNavController(
    @NonNull AppCompatActivity receiver,
    @NonNull NavController navController,
    DrawerLayout drawerLayout
)
```

Sets up the ActionBar returned by `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#getSupportActionBar()` for use with a `https://developer.android.com/reference/androidx/navigation/NavController`.

By calling this method, the title in the action bar will automatically be updated when the destination changes (assuming there is a valid `https://developer.android.com/reference/androidx/navigation/NavDestination#label()`).

The start destination of your navigation graph is considered the only top level destination. On the start destination of your navigation graph, the ActionBar will show the drawer icon if the given `drawerLayout` is non null. On all other destinations, the ActionBar will show the Up button.

You are responsible for calling `https://developer.android.com/reference/androidx/navigation/NavController#navigateUp()` to handle the Navigation button. Typically this is done in `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity#onSupportNavigateUp()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavController navController` | The NavController whose navigation actions will be reflected in the title of the action bar. |
| `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout drawerLayout` | The DrawerLayout that should be toggled from the Navigation button |