Resource Base
Table of contents

User Guide on Android (Java)

  • System Requirements:
    • Supported OS: Android 5 or higher (Android 7 or higher recommended).
    • Supported ABI: arm64-v8a/armeabi-v7a/x86/x86_64.
  • Environment: Android Studio 3.4+.


If you don’t have SDK yet, please download the Dynamsoft Camera Enhancer(DCE) SDK from the Dynamsoft website and unzip the package. After decompression, the root directory of the DCE installation package is DynamsoftCameraEnhancer, which is represented by [INSTALLATION FOLDER].

Build Your First Application

The following sample will demonstrate how to acquire a frame from video streaming by DCE.


  • The following steps are completed in Android Studio 4.2.
  • You can download the similar complete source code from Here.
  • For more samples on using Dynamsoft Camera Enhancer supporting Barcode Reader please click here.

Create a New Project

  1. Open Android Studio and select New Project… in the File > New > New Project… menu to create a new project.

  2. Choose the correct template for your project. In this sample, we’ll use Empty Activity.

  3. When prompted, choose your app name (HelloWorld) and set the Save location, Language, and Minimum SDK (21)

    Note: With minSdkVersion set to 21, your app is available on more than 94.1% of devices on the Google Play Store (last update: March 2021).

Include the library

There are two ways to include the Dynamsoft Camera Enhancer SDK into your project:

Local Binary Dependency

  1. Copy the file [INSTALLATION FOLDER]\Lib\DynamsoftCameraEnhancerAndroid.aar to the target directory HelloWorld\app\libs

  2. Open the file HelloWorld\app\build.gradle, and add reference in the dependencies:
     dependencies {
         implementation fileTree(dir: 'libs', include: ['*.aar'])
  3. Click Sync Now. After the synchronization completes, the SDK is added to the project.

  4. import the package int the file
     import com.dynamsoft.dce.*;

Remote Binary Dependency

  1. Open the file HelloWorld\app\build.gradle, and add the remote repository:
     repositories {
         maven {
             url ""
  2. Add reference in the dependencies:
     dependencies {
         implementation 'com.dynamsoft:dynamsoftcameraenhancer:{version-number}@aar'

    Note:Please replace {version-number} with the correct version number.

  3. Click Sync Now. After the synchronization completes, the SDK is added to the project.

  4. import the package in the file
     import com.dynamsoft.dce.*;

Initialize Dynamsoft Camera Enhancer

  1. Initialize the license

     CameraEnhancer.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", new DCELicenseVerificationListener() {
         public void DCELicenseVerificationCallback(boolean isSuccess, Exception error) {


    • Network connection is required for the license to work.
    • “DLS2***” is a default 7-day trial license used in the sample.
    • If the license has expired, please request a trial license through the customer portal.
  2. Create an instance of Dynamsoft Camera Enhancer

     CameraEnhancer mCameraEnhancer;
     mCameraEnhancer = new CameraEnhancer(MainActivity.this);

Create Camera View And Control Camera

  1. In the Project window, open app > res > layout > activity_main.xml, create a DCE camera view section under the root node.

         tools:layout_editor_absoluteY="0dp" />
  2. Initialize the camera view, and bind to the Camera Enhancer object.

     DCECameraView mCameraView;
     mCameraView = findViewById(;
  3. Override the MainActivity.onResume and MainActivity.onPause function to open and close camera.

     protected void onResume() {
         needCapture = false;
         try {
         } catch (CameraEnhancerException e) {
     protected void onPause() {
         try {
         } catch (CameraEnhancerException e) {

Capture Frame

  1. In the Project window, open app > res > layout > activity_main.xml, and add a Button to capture frame.
  2. Add UI variables and event response codes

     // Click to capture a frame
     private Button btnCapture;
     btnCapture =(Button)findViewById(;
     btnCapture.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
             // Here we just set a flag, the actual capture action will be executed in the `frameOutputCallback`
             needCapture = true;
  3. Add a frame listener to acquire the latest frame from video streaming. Here we capture a frame and show it on the other activity(ShowPictureActivity).

     static DCEFrame mFrame;
     mCameraEnhancer.addListener(new DCEFrameListener() {
         public void frameOutputCallback(DCEFrame frame, long nowTime) {
                 needCapture = false;
                 mFrame = frame;
                 Intent intent = new Intent(MainActivity.this,ShowPictureActivity.class);

Additional Steps

  1. In the Project window, open app > res > layout > activity_show_picture.xml, and add a ImageView.
  2. Display the captured frame in ImageView.

     public class ShowPictureActivity extends AppCompatActivity {
         ImageView ivPicture;
         protected void onCreate(Bundle savedInstanceState) {
             ivPicture = findViewById(;
             DCEFrame frame = MainActivity.mFrame;
             // Convert to Bitmap from the captured frame.
             Bitmap bitmap = frame.toBitmap();
             // Rotate it to the nature device orientation.
             bitmap = rotateBitmap(bitmap, frame.getOrientation());
             // Display it in ImageView
         private Bitmap rotateBitmap(Bitmap origin, float degree) {
             if (origin == null) {
                 return null;
             int width = origin.getWidth();
             int height = origin.getHeight();
             Matrix matrix = new Matrix();
             Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
             return newBM;

Build and Run the Project

  1. Select the device that you want to run your app on from the target device drop-down menu in the toolbar.

  2. Click Run app button, then Android Studio installs your app on your connected device and starts it.


  • You can download the similar complete source code from Here.
  • For more samples on using Dynamsoft Camera Enhancer supporting Barcode Reader please click here.

What’s next?

How to integration with barcode reader

This article guides you to integrate barcode reader function into your app.

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 1.0.3
  • Version 1.0.1
  • Version 1.0.0
Change +
© 2003–2021 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support