From f5db4277229e85cbf0bc8fa703e28fbfc9934cf5 Mon Sep 17 00:00:00 2001 From: Timur Baiguskarov Date: Wed, 10 Jun 2026 15:44:36 +0500 Subject: [PATCH] Update Android SDK for API 26.6 --- README.md | 28 ++++++++++--------- app/build.gradle | 2 +- .../barcode/cloud/demo_app/MainActivity.kt | 10 +++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9607c69..4087595 100644 --- a/README.md +++ b/README.md @@ -70,25 +70,27 @@ To use Aspose Barcode Cloud for Android you need to register an account with [As ## Getting Started -- Open project in Android Studio +- Open project in Android Studio. -- Go to file *app/src/main/java/com/example/asposebarcodecloud/MainActivity.kt* and set *clientId* and *clientSecret* to apropriate values from +- Go to `app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt` and set your `clientId` and `clientSecret` from . -- Build project and run application on connected device or emulator. +- Build the project and run the app on a connected device or emulator. -## Generate Code128 BbarCode in Android using Java +## Generate QR Barcode in Android using Kotlin -```java - // Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required). - ApiClient client = new ApiClient("MY_CLIENT_ID", "MY_CLIENT_SECRET"); +```kotlin +val client = ApiClient("MY_CLIENT_ID", "MY_CLIENT_SECRET") +val generateApi = GenerateApi(client) - BarcodeApi api = new BarcodeApi(client); +val request = GenerateRequestWrapper(EncodeBarcodeType.QR, "text example") +request.imageFormat = BarcodeImageFormat.PNG +request.qrEncodeMode = QREncodeMode.AUTO +request.qrErrorLevel = QRErrorLevel.LEVEL_M +request.qrVersion = QRVersion.AUTO +request.qrAspectRatio = 0.75f - String type = "code128"; - String text = "text example"; - - File result = api.getBarcodeGenerate(type, text); - System.out.println(result); +val result = generateApi.generate(request) +println(result?.absolutePath) ``` ## Licensing diff --git a/app/build.gradle b/app/build.gradle index cb8583d..9bb447a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.18.0' implementation 'androidx.appcompat:appcompat:1.7.1' implementation 'androidx.constraintlayout:constraintlayout:2.2.1' - implementation 'com.aspose:aspose-barcode-cloud:26.5.0' + implementation 'com.aspose:aspose-barcode-cloud:26.6.0' implementation 'com.google.android.material:material:1.13.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.3.0' diff --git a/app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt b/app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt index 353b871..c8902cf 100644 --- a/app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt +++ b/app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt @@ -54,6 +54,9 @@ import com.aspose.barcode.cloud.api.GenerateApi import com.aspose.barcode.cloud.api.ScanApi import com.aspose.barcode.cloud.model.BarcodeImageFormat import com.aspose.barcode.cloud.model.EncodeBarcodeType +import com.aspose.barcode.cloud.model.QREncodeMode +import com.aspose.barcode.cloud.model.QRErrorLevel +import com.aspose.barcode.cloud.model.QRVersion import com.aspose.barcode.cloud.requests.GenerateRequestWrapper import com.aspose.barcode.cloud.requests.ScanMultipartRequestWrapper import com.google.android.material.snackbar.Snackbar @@ -255,6 +258,13 @@ class MainActivity : AppCompatActivity() { genRequest.imageHeight = barcodeImgView.measuredHeight.toFloat() genRequest.imageWidth = barcodeImgView.measuredWidth.toFloat() + if (type == EncodeBarcodeType.QR) { + genRequest.qrEncodeMode = QREncodeMode.AUTO + genRequest.qrErrorLevel = QRErrorLevel.LEVEL_M + genRequest.qrVersion = QRVersion.AUTO + genRequest.qrAspectRatio = 0.75f + } + Thread { try { val generated = generateApi.generate(genRequest)