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.
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/" }
}
}
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.
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.
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();
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();
// 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();
// 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();
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 |
Resource Management: Always release resources when you're done using them to prevent memory leaks.
Error Handling: Implement proper error handling to provide a good user experience.
Performance Optimization:
Battery Efficiency: Minimize continuous processing to conserve battery life.
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.
For technical support, please contact us at support@duix.com or visit our developer portal at https://developer.duix.com.