https://github.com/star-micronics/starxpand-sdk-android
StarXpand SDK for Android is a software development kit for supporting application development for Star Micronics devices.
https://github.com/star-micronics/starxpand-sdk-android
Last synced: 21 days ago
JSON representation
StarXpand SDK for Android is a software development kit for supporting application development for Star Micronics devices.
- Host: GitHub
- URL: https://github.com/star-micronics/starxpand-sdk-android
- Owner: star-micronics
- License: other
- Created: 2022-01-27T10:48:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-08-26T05:53:46.000Z (10 months ago)
- Last Synced: 2025-08-26T07:22:56.273Z (10 months ago)
- Language: Kotlin
- Homepage: https://star-m.jp/starxpandsdk-oml.html
- Size: 12.6 MB
- Stars: 20
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
- [日本語はこちら](docs/README_JP.md)
# StarXpand SDK for Android
`StarXpand SDK for Android` is a software development kit for supporting application development for Star Micronics devices.
This software development kit provides the StarIO10 library (StarIO10.aar) as a library to control the Star Micronics devices.
## Documentation
Please refer [here](https://www.star-m.jp/starxpandsdk-oml.html) for StarXpand SDK documentation.
Documentation includes an overview of the SDK, how to build a sample application, how to use the API, and a API reference.
## About collection and transmission of diagnostic information By StarIO10 library
Some of the APIs provided by the StarIO10 library collect information about the user device and connected printer during execution and send it to the server managed by Star Micronics Co., Ltd. as diagnostic information.
Please refer [here](DIAG_INFO.md) for details.
## Requirements
| Language | StarIO10 Kotlin Version | Platform | Version[*](#OsVersion) | Arch | Test Environment[*](#TestEnvironment) |
| --- | --- | --- | --- | --- | --- |
| Kotlin | 1.7.21 | Android | Android 11.0 or later | arm64-v8a, armeabi-v7a, x86, x86_64 | Gradle 8.11.1, AGP 8.9.1 |
*The Bluetooth Low Energy interface is only supported on Android 12.0 and later.
*The sample app included with this SDK is being built, and its operation is being confirmed.
## Installation
### 1. Add the StarIO10 library to your project
In order to integrate the StarIO10 library into your Android application, Use Maven repository. Add the following dependencies to the `dependencies` block in `app/build.gradle`.
The `VERSION_NUMBER` part is the version of the library. Please refer to [app/build.gradle](app/build.gradle) for the latest version of the library.
```gradle
dependencies {
implementation 'com.starmicronics:stario10:VERSION_NUMBER'
...
}
```
For more information on how to integrate a library into your application, please refer to the following URL.
https://developer.android.com/studio/build/dependencies
### 2. Add settings to your project
#### 2.1. When using a Bluetooth interface
Refer to [sample code](app/src/main/java/com/starmicronics/starxpandsdk/ContentView.kt) and obtain BLUETOOTH_CONNECT and BLUETOOTH permission before starting Bluetooth(Classic) communication. Also, enable Bluetooth in the Android device's Bluetooth settings screen.
#### 2.2. To prevent the connection permission dialog from being displayed every time the USB cable is plugged in or unplugged
When communicating with a USB printer, a dialog box will appear asking for connection permission. This permission is reset when the USB cable is plugged in or unplugged (including when the printer is turned on or off).
If you do not want to display the connection permission dialog every time the USB cable is plugged in or unplugged, configure the following settings. This setting will also allow the application to start automatically when the USB cable is plugged.
##### 2.2.1. Add settings to AndroidManifest.xml
Add the following `` and `` elements to AndroidManifest.xml.
```xml
```
##### 2.2.2. Add a resource file
Store the following resource files under `res/xml` with the names `device_filter.xml` and `accessory_filter.xml`.
- device_filter.xml
```xml
```
- accessory_filter.xml
```xml
```
#### 2.3. When using the Bluetooth Low Energy interface
The Bluetooth Low Energy interface is only supported on Android 12.0 and later.
##### 2.3.1. Add settings to AndroidManifest.xml
Add the following `` elements to AndroidManifest.xml.
- If you need to obtain location information, the neverForLocation specification is not required.
```xml
```
##### 2.3.2. Bluetooth enablement
Refer to the [sample code](app/src/main/java/com/starmicronics/starxpandsdk/ContentView.kt) and obtain the necessary permissions before starting Bluetooth Low Energy communication. Also, enable Bluetooth in the Android device's Bluetooth settings screen.
##### 2.3.3. Perform pairing
When using Bluetooth Low Energy communication, pairing is required.
For pairing instructions, please refer to [here](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/pairing.html).
Please note that if the Android device is in silent mode, pairing may not be performed correctly. Please disable silent mode when performing pairing.
## Examples
StarXpand SDK includes an example application that can be used in combination with the printer to check its operation. Please use it in conjunction with the explanations of each function in the linked pages.
#### 1. [Discover printers](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/searchPrinter.html)
#### 2. [Create printing data](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/basic-step1.html)
The sample code and printed result images are also [available here](app/src/main/java/com/starmicronics/starxpandsdk/printingsamples/README.md).
- Sample to create print layouts for receipts and labels for each type of business
- Sample to generate receipt images from text data
> :warning: Some printer models may not be able to print some samples. Please adjust the layout accordingly when using this samples.
#### 3. [Create printing data using template printing function](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/template-step1.html)
#### 4. [Send printing data](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/basic-step2.html)
#### 5. [Send printing data using spooler function](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/spooler.html)
#### 6. [Get printer status](#GetPrinterStatus)
#### 7. [Monitor printer](#MonitorPrinter)
#### 8. [Update printer firmware](https://star-m.jp/products/s_print/sdk/starxpand/manual/en/fw-update.html)
### Get printer status
```kotlin
fun getStatus() {
// Specify your printer connection settings.
val settings = StarConnectionSettings(interfaceType.Lan, "00:11:62:00:00:00")
val printer = StarPrinter(settings, applicationContext)
val job = SupervisorJob()
val scope = CoroutineScope(Dispatchers.Default + job)
scope.launch {
try {
// Connect to the printer.
printer.openAsync().await()
// Get printer status.
val status = printer.getStatusAsync().await()
Log.d("Status", "${status}")
} catch (e: Exception) {
// Exception.
Log.d("Status", "${e.message}")
} finally {
// Disconnect from the printer.
printer.closeAsync().await()
}
}
}
```
### Monitor printer
```kotlin
fun monitor() {
val job = SupervisorJob()
val scope = CoroutineScope(Dispatchers.Default + job)
scope.launch {
// Specify your printer connection settings.
val settings = StarConnectionSettings(interfaceType.Lan, "00:11:62:00:00:00")
printer = StarPrinter(settings, applicationContext)
// Callback for printer state changed.
printer?.printerDelegate = object : PrinterDelegate() {
override fun onReady() {
super.onReady()
Log.d("Monitor", "Printer: Ready")
}
// ...
// Please refer to document for other callback.
}
printer?.drawerDelegate = object : DrawerDelegate() {
override fun onOpenCloseSignalSwitched(openCloseSignal: Boolean) {
super.onOpenCloseSignalSwitched(openCloseSignal)
Log.d("Monitor", "Drawer: Open Close Signal Switched: ${openCloseSignal}")
}
// ...
// Please refer to document for other callback.
}
printer?.inputDeviceDelegate = object : InputDeviceDelegate() {
override fun onDataReceived(data: List) {
super.onDataReceived(data)
Log.d("Monitor", "Input Device: DataReceived ${data}")
}
// ...
// Please refer to document for other callback.
}
printer?.displayDelegate = object : DisplayDelegate() {
override fun onConnected() {
super.onConnected()
Log.d("Monitor", "Display: Connected")
}
// ...
// Please refer to document for other callback.
}
try {
// Connect to the printer.
printer?.openAsync()?.await()
} catch (e: Exception) {
// Exception.
Log.d("Monitor", "${e.message}")
}
}
}
```
## Copyright
Copyright 2022 Star Micronics Co., Ltd. All rights reserved.