Appetize Docs
HomeDemoUploadPricing
  • Introduction
  • Platform
    • App Management
      • Uploading Apps
        • Android
        • iOS
      • App Dashboard
      • Running Apps
      • App Permissions
    • Device Sandbox
    • Embedding
    • Sharing
    • Session Inactivity Timeout
    • Query Params Reference
  • Features
    • Devices & OS Versions
    • Network Traffic Monitor
    • Debug Logs
    • UI Automation
    • Proxy
    • Language & Locale
    • Mock Location
    • Deep links
    • Launch Params
    • Media
    • Auto-grant Permissions
    • Custom Branding
    • Custom Launch Pages
    • Advanced Features
      • Android
        • ADB tunnel
        • Hide Password Visibility
      • Reserved Devices
  • Account
    • Invite your team
    • Single Sign-On
      • OpenID Connect
      • SAML
      • Azure Active Directory
      • Google Workspace (GSuite)
    • Reporting
      • Session History
      • Usage Summary
  • Infrastructure
    • Configure Network Access
    • Enterprise Hosting Options
  • JavaScript SDK
    • Configuration
    • Automation
      • Device commands
      • Touch interactions
    • API reference
      • Initialization
      • Client
      • Session
      • Types
        • AdbConnectionInfo
        • AppetizeApp
        • AndroidElementAttributes
        • Coordinates
        • DeviceInfo
        • Element
        • ElementBounds
        • IOSAccessibilityElement
        • IOSElementAttributes
        • NetworkRequest
        • NetworkResponse
        • SessionConfig
        • SwipeMove
        • RecordedAction
        • RecordedSwipeAction
        • RecordedKeypressAction
        • RecordedPosition
        • RecordedTapAction
        • RecordedTouchAction
        • UserInteraction
  • Testing
    • Getting Started
    • Writing Tests
    • Running Tests
    • Test Configuration
    • Continuous Integration
    • Record Tests (experimental)
    • Trace Viewer
    • Web Tests on Mobile Browsers
  • REST API
    • Create new app
    • Update existing app
    • Direct file uploads
    • Delete app
    • List apps
    • Usage summary
    • Devices & OS Versions
      • v1
    • IP Blocks
      • v1
    • Sample code
  • Guides & Samples
    • Impersonation
    • Automate Sign-in Flow
    • Screenshot Automation
    • Unlock Device
    • Validate Analytics Events
    • Lock Your Device to One App
    • Test Accessibility Font Sizes
    • Common testing scenarios
    • Samples Repository
  • Deprecated
    • Cross-document messages
  • Changelog
  • Additional Support
    • Knowledge Base
    • Support Request
Powered by GitBook
On this page
  • JavaScript SDK Setup
  • Enabling App Pinning
  • Disable System Toasts (Optional)
  1. Guides & Samples

Lock Your Device to One App

Learn how to enable App Pinning (Kiosk Mode) on Android to lock your device to a single application for a more controlled previewing environment.

PreviousValidate Analytics EventsNextTest Accessibility Font Sizes

Last updated 1 month ago

App Pinning is currently only available on Android devices

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 and 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 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.

Pin Running Application
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);
}
  • 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.

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.

async function disableToastMessages(session) {
    await session.adbShellCommand('appops set com.android.systemui TOAST_WINDOW deny');
}
JavaScript SDK
Getting Started
adbShellCommand