Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Android

Perry compiles TypeScript apps for Android using JNI (Java Native Interface).

Requirements

  • Android NDK
  • Android SDK
  • Rust Android targets:
    rustup target add aarch64-linux-android armv7-linux-androideabi
    

Building

perry app.ts -o app --target android

UI Toolkit

Perry maps UI widgets to Android views via JNI:

Perry WidgetAndroid Class
TextTextView
ButtonButton
TextFieldEditText
SecureFieldEditText (ES_PASSWORD)
ToggleSwitch
SliderSeekBar
PickerSpinner + ArrayAdapter
ImageImageView
VStackLinearLayout (vertical)
HStackLinearLayout (horizontal)
ZStackFrameLayout
ScrollViewScrollView
CanvasCanvas + Bitmap
NavigationStackFrameLayout

Android-Specific APIs

  • Dark mode: Configuration.uiMode detection
  • Preferences: SharedPreferences
  • Keychain: Android Keystore
  • Notifications: NotificationManager
  • Open URL: Intent.ACTION_VIEW
  • Alerts: PerryBridge.showAlert
  • Sheets: Dialog (modal)

Splash Screen

Perry’s Android template includes a splash theme (Theme.Perry.Splash) that displays a windowBackground drawable during cold start. Configure it via perry.splash in package.json:

{
  "perry": {
    "splash": {
      "image": "logo/icon-256.png",
      "background": "#FFF5EE"
    }
  }
}

The image is centered via a layer-list drawable with a solid background color. The activity switches to the normal theme in onCreate before inflating the layout, so the splash disappears as soon as the app is ready.

For full control, provide custom drawable and theme XML files:

{
  "perry": {
    "splash": {
      "android": {
        "layout": "splash/splash_background.xml",
        "theme": "splash/themes.xml"
      }
    }
  }
}

See Project Configuration for the full config reference.

Differences from Desktop

  • Touch-only: No hover events, no right-click context menus
  • Single window: Multi-window maps to Dialog views
  • Toolbar: Horizontal LinearLayout
  • Font: Typeface-based font family support

Next Steps