Android Service example

This example demonstrates the usage of the Kanzi Android Service to provide Kanzi functionality to multiple independent client applications. The applications use seamless cross-application transition animations when switching between them.

The example also shows prefab preloading. When you launch the service host application before starting a client, the service preloads Kanzi content so that the client can display the Kanzi content immediately.

Requirements

  • JDK 17

  • Gradle 8.7

  • Android Gradle plugin 8.6.0

  • Android Studio Giraffe or newer

  • Android device or emulator with API level 29+

Getting the example

To get the example, in the Kanzi Studio Quick Start window, click Examples. Next to the Transition Animation example, click download.

Kanzi Studio downloads the example to the <KanziWorkspace>/Examples/Android/TransitionAnimation directory.

Contents

The example consists of three main components:

  • Application/android-service: An application that hosts the Kanzi Android Service and sets up prefab preloading.

  • Launcher: A client application with a View based UI that shows the home screen.

  • Settings: A client application with a View based UI that shows interactive car controls.

Both client applications use the single Kanzi instance hosted by the service host application.

Building and installing

To build and install the example:

  1. Ensure that your Android device or emulator is running and connected.

  2. Build and install each of the applications:

    cd Examples/Android/TransitionAnimation/Application/android-service
    ./gradlew installRelease
    
    cd Examples/Android/TransitionAnimation/Launcher
    ./gradlew installRelease
    
    cd Examples/Android/TransitionAnimation/Settings
    ./gradlew installRelease
    
  3. Grant Display over other apps permission:

    • Go to Settings > Apps > [App] > Advanced > Display over other apps

    • Enable the permission for the Launcher, Settings, and ServiceHost applications

    Note

    On Android automotive devices it is not possible to grant the Display over other apps permission for newly installed apps using the Android UI. The other way to grant this permission is to sign the apps with the platform keys.

  4. Launch the Launcher application from the app drawer. The client app automatically connects to the Kanzi Android Service and displays the Kanzi content.

  5. Use the bottom navigation bar to switch between the Launcher and Settings applications. The cross-app transition animation is shown during the switch.

See also

Developing with the Kanzi Android framework (droidfw)

Developing with the Kanzi Android Service