SDK Integration
Quick Integration
Before using the SDK, you need to integrate it into your development environment first.
- Copy DFQRScanner.aar to libs folder of your project.
Add the following code to the build.gradle in your project.
repositories { flatDir { dirs project(':DFKYCLibrary').file('libs') } } dependencies { implementation(name: 'DFQRScanner', ext: 'aar') }
Launch QRScanner
Init API_ID and API_SECRET
Intent scannerIntent = DFScannerUtils.getScannerIntent(this, API_ID, API_SECRET);
Start scanner activity
// 100 means requestCode
startActivityForResult(scannerIntent, 100);
Get SDK result
// 100 means requestCode
if (requestCode == 100) {
if (resultCode == DFScannerUtils.RESULT_CODE_QR_SCAN_SUCCESS) {
// Scan success
DFScanResult scanResult = (DFScanResult) data.getSerializableExtra(DFScannerUtils.INTENT_EXTRA_KEY_QR_SCAN);
Log.i("DFScannerUtils", scanResult.toString());
} else {
// Scan failed
DFErrorModel errorModel = (DFErrorModel) data.getSerializableExtra(DFScannerUtils.INTENT_EXTRA_ERROR_MESSAGE);
Log.i("DFScannerUtils", "fail" + errorModel.getReason());
}
}
Code Confusion
Add the following code in proguard file if you want to confuse code:
-keep class com.deepfinch.** {*;}
Require Camera Permission
SDK needs to request camera permission before using, reference to DFPermissionUtil.java file in SDK sample.