Android Service example¶
This example demonstrates the usage of the Kanzi Android Service to provide Kanzi functionality to multiple independent client applications.
Requirements¶
JDK 17
Gradle 8.0 or newer
Android Gradle plugin 8.1.2 or newer
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 Android Service example, click .
Kanzi Studio downloads the example to the <KanziWorkspace>/Examples/Android/Service directory.
Contents¶
The example consists of three main components:
Application/android_service: This is an application that hosts the Kanzi Android Service.
ClientBlue: A client application with a View based UI that embeds Kanzi content.
ClientRed: A client application with a View based UI that embeds Kanzi content.
Both client applications use the single Kanzi instance hosted by the service host application.
Building and installing¶
Ensure that your Android device or emulator is running and connected.
Build and install each of the applications:
cd Examples/Android/Service/Application/android_service ./gradlew installRelease cd Examples/Android/Service/ClientBlue ./gradlew installRelease cd Examples/Android/Service/ClientRed ./gradlew installRelease
Grant
Display over other appspermission:Go to Settings > Apps > [Client App] > Advanced > Display over other apps
Enable the permission for both ClientBlue, ClientRed 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.
Launch either ClientBlue or ClientRed from the app drawer. The client app automatically connects to the Kanzi service and displays the Kanzi content.
Use the
Go tobutton to switch between the client applications. The cross-app transition animation is shown during the switch.