# Lock Your Device to One App

{% hint style="info" %}
App Pinning is currently only available on Android devices
{% endhint %}

App pinning, also known as Kiosk Mode, is a feature that restricts users to a single app, preventing access to other applications, settings, or the home screen. This is especially useful in scenarios where you want to restrict access to other parts of the device.

In this guide we will cover how you can enable app pinning for the current running application using our [JavaScript SDK](/javascript-sdk.md) and [adbShellCommand](/javascript-sdk/automation/device-commands.md#adbshellcommand) functionality.

## JavaScript SDK Setup

Before enabling App Pinning, you need to ensure that the Appetize JavaScript SDK is properly set up in your project. The SDK allows you to control various aspects of the device, including sending ADB shell commands.

Follow our [Getting Started](/javascript-sdk.md) steps to set up the JavaScript SDK.

## Enabling App Pinning

Once the SDK is set up and a session has started, you can enable **App Pinning** to lock a specific app in the foreground. Use the function below, providing the package name of the app you want to pin.

{% code title="Pin Running Application" overflow="wrap" fullWidth="false" %}

```typescript
async function pinRunningApp(session, packageName) {
    // Apply app pinning to the currently launched application
     const command = "'taskId=$(am stack list | grep -E -m 1 -o \"taskId=[0-9]+: " + 
        packageName + 
        "\" | grep -E -o \"[0-9]+\"); am task lock $taskId'";
    await session.adbShellCommand(command);
}
```

{% endcode %}

{% hint style="info" %}

* `packageName` should be the full Android package name of the app you want to pin (e.g.`"com.example.myapp"`).
* The app **must already be running** before calling this function, as the command looks for its active task in the stack.
  {% endhint %}

## Disable System Toasts (Optional)

You can choose to disable toast notifications during the session, such as the confirmation message indicating that your app has been pinned. This is optional and can help reduce distractions or clutter.

```typescript
async function disableToastMessages(session) {
    await session.adbShellCommand('appops set com.android.systemui TOAST_WINDOW deny');
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.appetize.io/guides-and-samples/lock-your-device-to-one-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
