# Android SDK

# Introduction

DUIX ONE-Offline Android SDK is a local version of the DUIX ONE SDK that provides offline capabilities. It allows developers to integrate DUIX's AI capabilities into Android applications without requiring an internet connection.

# Integration Guide

# Environment Requirements

  • Android Studio 3.0 or above
  • minSdkVersion 21 or above
  • Gradle 4.1 or above
  • JDK 1.8 or above

# Integration Steps

# 1. Add Repository

Add the following repository to your project's build.gradle file:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        // Add DUIX repository
        maven { url "https://maven.duix.com/repository/maven-public/" }
    }
}

# 2. Add Dependencies

Add the following dependencies to your app's build.gradle file:

dependencies {
    // DUIX ONE-Offline SDK
    implementation 'com.duix.sdk:offline:x.x.x'
    
    // Required support libraries
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'androidx.core:core-ktx:1.5.0'
}

Replace x.x.x with the latest version of the SDK.

# 3. Initialize SDK

Initialize the SDK in your Application class:

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        // Initialize DUIX ONE-Offline SDK
        DuixOfflineConfig config = new DuixOfflineConfig.Builder()
            .setAppId("your_app_id")
            .setAppKey("your_app_key")
            .build();
            
        DuixOfflineSDK.init(this, config);
    }
}

Don't forget to register your Application class in the AndroidManifest.xml file.

# API Reference

# Core Classes

# DuixOfflineSDK

The main entry point for the SDK.

// Initialize SDK
DuixOfflineSDK.init(context, config);

// Check if SDK is initialized
boolean isInitialized = DuixOfflineSDK.isInitialized();

// Get SDK version
String version = DuixOfflineSDK.getVersion();

# DuixOfflineConfig

Configuration class for the SDK.

DuixOfflineConfig config = new DuixOfflineConfig.Builder()
    .setAppId("your_app_id")
    .setAppKey("your_app_key")
    .setDebugMode(true)  // Enable debug mode
    .setLogLevel(LogLevel.VERBOSE)  // Set log level
    .build();

# Feature APIs

# Text Recognition

// Create text recognizer
DuixTextRecognizer recognizer = DuixOfflineSDK.createTextRecognizer();

// Recognize text from image
recognizer.recognizeText(bitmap, new TextRecognitionCallback() {
    @Override
    public void onSuccess(TextRecognitionResult result) {
        // Handle success
        String text = result.getText();
    }
    
    @Override
    public void onError(DuixError error) {
        // Handle error
        int code = error.getCode();
        String message = error.getMessage();
    }
});

// Release resources when done
recognizer.release();

# Image Classification

// Create image classifier
DuixImageClassifier classifier = DuixOfflineSDK.createImageClassifier();

// Classify image
classifier.classify(bitmap, new ClassificationCallback() {
    @Override
    public void onSuccess(ClassificationResult result) {
        // Handle success
        List<Classification> classifications = result.getClassifications();
    }
    
    @Override
    public void onError(DuixError error) {
        // Handle error
    }
});

// Release resources when done
classifier.release();

# Error Codes

Code Description
1001 SDK not initialized
1002 Invalid parameters
1003 License expired
2001 Model loading failed
2002 Processing error
3001 Out of memory
3002 Internal error

# Best Practices

  1. Resource Management: Always release resources when you're done using them to prevent memory leaks.

  2. Error Handling: Implement proper error handling to provide a good user experience.

  3. Performance Optimization:

    • Process images at an appropriate resolution
    • Run heavy operations in background threads
    • Cache results when appropriate
  4. Battery Efficiency: Minimize continuous processing to conserve battery life.

# FAQ

Q: How large are the offline models?

A: The size of offline models varies depending on the features you use, typically ranging from 10MB to 100MB.

Q: Can I use the SDK without an internet connection?

A: Yes, once the SDK is properly initialized and the models are downloaded, it can function completely offline.

Q: How often are the offline models updated?

A: We release model updates quarterly, but you can continue using existing models indefinitely.

Q: Is there a limit to the number of API calls in offline mode?

A: No, there are no API call limits in offline mode, but there may be device performance limitations.

# Support

For technical support, please contact us at support@duix.com or visit our developer portal at https://developer.duix.com.