Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://dashboard.aspose.cloud/applications>
- Go to `app/src/main/java/com/aspose/barcode/cloud/demo_app/MainActivity.kt` and set your `clientId` and `clientSecret` from <https://dashboard.aspose.cloud/applications>.

- 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
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading