MOVERIO
BT-35E Documentation

2. Developing Android Apps

2.1. Summary of Developing Android Apps

The following describes the steps necessary to develop an Android app for Moverio.

Introduction to the Android SDK

Including the Moverio SDK

API Reference

Range of Uses for Moverio SDK

2.1.1 Introduction to the Android SDK

The introduction to the Android SDK assumes the following steps will be performed in a Windows 10 environment.

2.1.1.1 Acquiring Android Studio

Download Android Studio from the following website. (Android Studio 3.1.4 as of August 2018)
https://developer.android.com/studio/

2.1.1.2 Installing Android Studio

Follow the directions provided by the installer to install Android Studio.

Example) C:\Users\<user name>name\AppData\Local\Android\sdk
* From here on, instructions assume Android Studio is installed in the folder above.

2.1.1.3 Proxy Settings for Android Studio

If you are developing an app in a network environment that requires proxy settings, make sure you make proxy settings for Android Studio. See the following website for details on the procedures.
https://developer.android.com/studio/intro/studio-config#gradle-plugin
If you do not know the proxy settings, contact your network administrator for information on how to connect to an external network using proxy settings.

2.1.1.4 Acquiring/Updating Tools in Android SDK Manager

Make sure you use the Android SDK Manager to acquire the tools necessary for app development. See the following website for details on the procedures.
https://developer.android.com/studio/intro/update#sdk-manager

2.1.2 USB Driver Settings

You need to setup the USB driver for your host device to connect to the app development computer. To setup your USB driver, check the setup instructions for your host device.

2.1.3 Connecting the Host Device and Computer

This section explains how to connect the computer and the host device after you have finished making ADB settings.

2.1.3.1 Settings for the Host Device

Enable the developer option for the host device. Next, enable USB debugging. See the following website for details on the procedures.
https://developer.android.com/studio/debug/dev-options

2.1.3.2 Checking the Connection

You can check if the computer and the host device are connected by using the ADB connection check command.
Start the command prompt, run "cd C:\Users\<user name>\AppData\Local\Android\sdk\platform-tools",
and move the folder.
* It is useful to maintain the environment variable path mentioned above.

When you execute "adb devices" and the device name is displayed in the list, ADB connection is complete.

* If this is not displayed, reconnect the host device to the USB port, and rerun the "adb devices" command.

2.1.4 Including the Moverio SDK

The following procedures assume app development in Android Studios.

Display the Project View in Android Studio, and then create a "libs" folder from [File]-[New]-[Directory].
C:\Users\<user name>\AndroidStudioProjects\<application name>\app\libs is created; put MoverioSDK.aar in this folder.
(When the created project folder is C:\Users\<user name>\AndroidStudioProjects)
* Explanations from now on are based on the assumption that the project is at C:\Users\<user name>\AndroidStudioProjects\<application name>.
Next, the minimum API level of the application is defined as 24, add MoverioSDK.aar to your application's dependencies.

apply plugin:  'com.android.application'

android {
        :
    // Add API level 24
    minSdkVersion 24
        :
}

dependencies {
        :
    // Add MoverioSDK.aar
    implementation files('libs/MoverioSDK_1.0.0.aar')
        :
        :
}

Press the Sync Project with Gradle Files button above Android Studio to apply the Gradle change to the project.

2.2. Display Management

The Moverio has a see-through (transparent) display. The Moverio SDK allows you to manage the brightness of the display and switch between 2D/3D display mode. You can adjust the brightness of the display by using the dedicated API and by using the auto adjust method according to the brightness of the surroundings. The Side-by-Side method for displaying 3D content is also supported.

See related information.

Adjusting the Display Brightness

Switching Between 2D/3D Display Mode

Model Correspondence Table for Display Management

API Reference

Sample Code

2.2.1. Adjusting the Display Brightness

Since the Moverio has a see-through display, the visibility for displayed images changes due to the effect of the brightness of the surroundings. If the surroundings are bright, increase the brightness of the display; if the surroundings are dark, decrease the brightness to make the displayed image easier to view.

To adjust the brightness of the display, you first need to establish communication with the Moverio's display. To do this, create an instance of the DisplayManager class, and then call the open() method.

* When using the Moverio SDK's DisplayManager class, import com.epson.moverio.hardware.display.DisplayManager to avoid name conflict with the Android standard DisplayManager class, or set the class name at instance creation to com.epson.moverio.hardware.display.DisplayManager.

e.g. Import com.epson.moverio.hardware.display.DisplayManager

import com.epson.moverio.hardware.display.DisplayManager;

e.g. Create an instance of com.epson.moverio.hardware.display.DisplayManager

public class DisplayActivity extends Activity {
    private com.epson.moverio.hardware.display.DisplayManager mDisplayManager = null;

Next, set the display brightness adjustment mode to manual or automatic. Use the setBrightnessMode() method to make settings. For manual mode, pass the BRIGHTNESS_MODE_MANUAL argument, and for automatic mode pass the BRIGHTNESS_MODE_AUTOMATIC argument. When the display brightness adjustment mode is set to automatic, you cannot adjust the display brightness using the setBrightness() method.

To manually adjust the brightness of the display, use the setBrightness() method. See Available brightness adjustment range for more information on the available brightness adjustment range.

When you have finished adjusting the brightness of the display, make sure you end communication with the Moverio's display. To end communication, use the close() method.

private DisplayManager mDisplayManager = new DisplayManager(context);
try {
    mDisplayManager.open();
} catch (IOException e) {
    e.printStackTrace();
}
mDisplayManager.setBrightnessMode(DisplayManager.BRIGHTNESS_MODE_MANUAL);
mDisplayManager.setBrightness(15);
mDisplayManager.close();

2.2.2. Switching Between 2D/3D Display Mode

The Moverio's display supports the Side-by-Side method for displaying 3D content. When displaying 3D content in Moverio using the Side-by-Side method, make sure you use the dedicated API to manage operations from the app.

The side by side method places images on the left and right of the screen.

When creating images using the Side-by-Side method, place the left eye image and the right eye image on the left and right sides of the image respectively.

For example, when creating a 1280 × 720 (HD size) Side-by-Side image, place a 640 × 720 image for the left eye and a 640 × 720 image for the right eye as shown in the following figure to build the Side-by-Side image.

To switch the 2D/3D display mode, you first need to establish communication with the Moverio's display. To do this, create an instance of the DisplayManager class, and then call the open() method.

Next, set the 2D/3D display mode for the display to 2D or 3D. Use the setDisplayMode() method to make settings. For 2D display mode, pass the DISPLAY_MODE_2D argument, and for 3D display mode pass the DISPLAY_MODE_3D argument.

When you have finished switching the 2D/3D display mode for the display, make sure you end communication with the Moverio's display. To end communication, use the close() method.

private DisplayManager mDisplayManager = new DisplayManager(context);
try {
    mDisplayManager.open();
} catch (IOException e) {
    e.printStackTrace();
}
mDisplayManager.setDisplayMode(DisplayManager. DISPLAY_MODE_3D);
mDisplayManager.close();

2.2.3. Creating Images Using the See-Through Type Display

The Moverio is equipped with a see-through type display that allows the wearer to superimpose images over their real-time surroundings. To superimpose the image of an object you want to display in Moverio over the wearers real-time surroundings, you can create an image that makes use of the see-through display by setting the background of the object you want to display to black.

2.2.4. Available brightness adjustment range

See following table on the available brightness adjustment range.

model brightness adjustment range
BT-35E 0 to 20
BT-30C 0 to 20

2.3. Camera Management

The Moverio headset is equipped with a camera that captures images in front of the user. You can use the Moverio SDK to acquire camera image data, capture still and video images, and so on. You can use camera image data not only for normal image capturing but also for functions such as marker recognition.

Please refer to the related information.

Camera specifications

Preview display

Acquiring camera image data

Capturing still and video images

Changing camera properties

Permission requests

Save still and video images to SD card

Notes on camera control

Model Correspondence Table for Camera Management

API reference

Sample code

2.3.1. Camera specifications

Item BT-35E
Effective pixels 5 million pixels
Color array RGB565
Resolution/ Frame rate 640×480, 60fps/30fps/15fps
1280×720, 60fps/30fps/15fps
1920×1080, 30fps/15fps
2592×1944, 15fps
Exposure compensation mode auto/manual
Manual exposure compensation step -5 to +5
Sharpness 0 to +128
White balance auto
/cloudy_daylight(6000K)/daylight(5500K)
/fluorescent(4200K)/incandescent(3200K)
/twilight(3500K)
Power line frequency 50Hz/60Hz

2.3.2. Preview display

You can use the Moverio SDK to enable display of the camera preview equipped to the Moverio.

To display the preview, you first need to establish communication with the Moverio camera. To do this, create an instance of the CameraManager class, and then call the open() method. When doing so, pass the SurfaceHolder of SurfaceView used for preview display as an argument. Next, call the startCapture() method of the CameraDevice class to start acquiring the camera image data. Then, call the startPreview() method of the CameraDevice class to display the preview image in the SurfaceView of the SurfaceHolder that was passed by the open() method argument. For the color array of the camera image data, refer to Camera specifications.

* When using the Moverio SDK's CameraManager class, import com.epson.moverio.hardware.camera.CameraManager to avoid name conflict with the Android standard CameraManager class, or set the class name at instance creation to com.epson.moverio.hardware.camera.CameraManager.

e.g. Import com.epson.moverio.hardware.camera.CameraManager

import com.epson.moverio.hardware.camera.CameraManager;

e.g. Create an instance of com.epson.moverio.hardware.camera.CameraManager

public class CameraActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
    private com.epson.moverio.hardware.camera.CameraManager mCameraManager = null;

Call the stopPreview() method to stop the preview display. When you finish using the camera, call the stopCapture() method to stop acquiring camera image data, and then call the close() method to stop communication with the camera.

public class CameraActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
    private CameraManager mCameraManager = null;
    private CameraDevice mCameraDevice = null;
    private SurfaceView mSurfaceView = null;

    private CaptureStateCallback mCaptureStateCallback =new CaptureStateCallback() {
        @Override
        public void onCaptureStarted() {
            mCameraDevice.startPreview();
        }
            :
            [Omitted]
            :
    };

    @Override
    public final void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
        mCameraManager = new CameraManager(this);
        try {
            mCameraDevice = mCameraManager.open(mCaptureStateCallback, null, mSurfaceView.getHolder());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCameraDevice.startCapture();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mCameraDevice.stopPreview();
        mCameraDevice.stopCapture();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCameraManager.close(mCameraDevice);
    }
}

2.3.3. Acquiring camera image data

You can use the Moverio SDK to acquire image data of the camera equipped to the Moverio.

To acquire camera image data, you first need to establish communication with the Moverio camera. To do this, create an instance of the CameraManager class, and then call the open() method. When doing so, pass an instance of the CaptureDataCallback that received the data as an argument. Then, call the startCapture() method of the CameraDevice class to receive data for the instance of the CaptureDataCallback that was passed by the open() method argument.

Call the stopCapture() method to stop acquiring camera image data. When you finish acquiring camera image data, call the close() method to stop communication with the camera.

public class CameraActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
    private CameraManager mCameraManager = null;
    private CameraDevice mCameraDevice = null;
    private SurfaceView mSurfaceView = null;

    private CaptureStateCallback mCaptureDataCallback =new CaptureStateCallback() {
        @Override
        public void onCaptureData(long timestamp, byte[] data) {
            // Do something with this camera data.
        }
    };

    @Override
    public final void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mCameraManager = new CameraManager(this);
        try {
            mCameraDevice = mCameraManager.open(null, mCaptureDataCallback, mSurfaceView.getHolder());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCameraDevice.startCapture();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mCameraDevice.stopCapture();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCameraManager.close(mCameraDevice);
    }
}

2.3.4. Capturing still and video images

You can use the Moverio SDK to capture image data of the camera equipped to the Moverio as still and video images.

To capture still and video images, you first need to establish communication with the Moverio camera. To do this, create an instance of the CameraManager class, and then call the open() method. When doing so, pass the instance of the CaptureStateCallback that received the status notification of still image capture completed, or start/stop video capture as an argument. Next, call the startCapture() method of the CameraDevice class.

If you want to capture still images, call the takePicture() method of the CameraDevice class. You can receive a notification that still image capture is completed by using the onPictureCompleted() method of the instance of the CaptureStateCallback that was passed by the open() method argument.

If you want to start recording video images, call the startRecord() method of the CameraDevice class, and if you want to stop recording video, call the stopRecord() method of the CameraDevice class. You can receive a notification that video recording has started/stopped by using the onRecordStarted() method or onRecordStopped() method of the instance of the CaptureStateCallback that was passed by the open() method argument. Recording of video images can be performed for up to a maximum of two hours. Video recording will be forcibly stopped if it exceeds two hours. It will also be forcibly stopped if the storage capacity drops below 10% while recording video. Execution of the stopRecord () method inside a method such as onStop / onDestroy of the Activity life cycle will result in an error.

When you finish using the camera, call the stopCapture() method to stop capturing camera image data, and then call the close() method to stop communication with the camera.

2.3.5. Changing camera properties

You can use the Moverio SDK to change the properties of the camera equipped to the Moverio.

To change camera properties, you first need to establish communication with the Moverio camera. To do this, create an instance of the CameraManager class, and then call the open() method. When doing so, pass the instance of the SurfaceHolder of the SurfaceView used for preview or of the CaptureDataCallback that received the data as an argument. Next, call the getProperty() method of the CameraDevice class, and then acquire the current camera properties as an instance of the CameraProperty class. To change a camera property, call the corresponding setXXX() method of the instance of the CameraProperty class.

For example, if you want to change the camera exposure step, call the setExposureStep() method of the CameraProperty. When doing so, pass the camera exposure step to be effective after changing as an argument.

Next call the setProperty() method of the CameraDevice class to reflect the camera properties after changing in the camera images. When doing so, pass the instance of the CameraProperty class for the camera property to be effective after changing as an argument.

Some camera properties can be changed even after camera images are captured by using the startCapture() method.

Item Before capture After capture
Resolution/ Frame rate Can be changed Cannot be changed
Exposure compensation mode Can be changed Can be changed
Manual exposure compensation step Can be changed Can be changed
Sharpness Can be changed Can be changed
White balance Can be changed Can be changed
Power line frequency Can be changed Can be changed

The manual exposure compensation step can be changed according to the ambient illumination [lx] of the usage environment. However, the exposure compensation step that supports high ambient illumination may affect the frame rate of the camera image because the exposure time of the camera is extended to handle high ambient illumination. Details are described in the table below.

Manual exposure correction step Ambient illumination [lx] Maximum frame rate [fps]
+5 50 5.0
+4 100 10.0
+3 150 22.6
+2 200 30.1
+1 500 45.2
0 (=default) 750 60.0*1
-1 1000 60.0*1
-2 1500 60.0*1
-3 2000 60.0*1
-4 4500 60.0*1
-5 9000 60.0*1

*1 The frame rate of Moverio's camera image is up to 60 fps. Also, the frame rate may be reduced due to the processing performance of the host device.

public class CameraActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback {
    private CameraManager mCameraManager = null;
    private CameraDevice mCameraDevice = null;
    private SurfaceView mSurfaceView = null;

    private CaptureStateCallback mCaptureStateCallback =new CaptureStateCallback() {
        @Override
            public void onCaptureStarted() {
            mCameraDevice.startPreview();
        }
                :
                [Omitted]
                :
    };

    @Override
    public final void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_camera);

        mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
        mCameraManager = new CameraManager(this);
        try {
            mCameraDevice = mCameraManager.open(mCaptureStateCallback, null, mSurfaceView.getHolder());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        mCameraDevice.startCapture();
        CameraProperty property = mCameraDevice.getProperty();
        property.setExposureMode(CameraProperty.EXPOSURE_MODE_MANUAL);
        property.setExposureStep(5);
        mCameraDevice.setProperty(property);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mCameraDevice.stopPreview();
        mCameraDevice.stopCapture();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mCameraManager.close(mCameraDevice);
    }
}

2.3.6. Permission requests

You can send a permission request to Android device users when they are using an application developed by using the Moverio SDK for the first time. Requested permissions are as follows.

Item Request Timing
Camera * Android 9 or later. When the CameraManager#open() method is called
USB communication When the CameraManager#open() method is called
File writing to storage when still/video image capturing is performed When the CameraDevice#startCapture() method is called
Permission for sound recording when recording images When the CameraDevice#startCapture() method is called

The application is equipped with an ActivityCompat.OnRequestPermissionsResultCallback interface to receive that the user has granted permission. When doing so, call the onRequestPermissionResult() method of the PermissionHelper class to notify the Moverio SDK that the user has granted permission. Use of the camera function is enabled when the Moverio SDK is notified that user permission has been granted.

2.3.7. Save still and video images to SD card

Access the application data storage area inside the SD card to save the still / video images shooting results on the SD card. Specify the following path in the takePicture() method of the CameraDevice class or the startRecord() method of the CameraDevice class.

[Path of the SD card]/Android/data/[Package name of Application]/[File name]

2.3.8. Notes on camera control

Camera control using the Moverio SDK can only be used with a single application at one time. If you want to control the camera using a different application, you must first always stop use of camera control by the application that is currently using it.

2.4. Sensor Management

The Moverio is equipped with a variety of sensors that detect movement, direction, and environment. You can use the Moverio SDK to capture the raw data from these sensors. The sensor data can be used to calculate the head movement of the user and the brightness of the surrounding environment.

Please refer to the related information.

Sensor type

Sensor axis

Acquiring sensor data

Model Correspondence Table for Sensor Management

API Reference

Sample code

2.4.1 Sensor type

The Moverio is equipped with various types of sensors. These sensors consist of both hardware and software-based types. Hardware-based sensors include those for acceleration, magnetic field, angular velocity, and surrounding ambient light. Software-based sensors consist of virtual sensors that use values output by a single or multiple hardware-based sensors. Virtual sensors can calculate items such as rotation vectors and gravity.

Sensor Type Description Use example
TYPE_ACCELEROMETER Hardware Measures the acceleration of the Moverio, including gravity, along the three axises (X, Y, and Z) in [m/s²]. Motion detection (slanting and so on)
TYPE_MAGNETIC_FIELD Hardware Measures the surrounding magnetic field along the three axises (X, Y, and Z) in [µT]. Position detection
TYPE_GYROSCOPE Hardware Measures the angular velocity of the Moverio along the three axises (X, Y, and Z) in [rad/s]. Motion detection (rotation and so on)
TYPE_LIGHT Hardware Measures the surrounding ambient light in [lx]. Display brightness adjustment according to the surrounding ambient light
TYPE_GRAVITY Software Measures the acceleration of gravity along the three axises (X, Y, and Z) in [m/s²]. Motion detection (slanting and so on)
TYPE_LINEAR_ACCELERATION Software Measures the acceleration along the three axises (X, Y, and Z) with gravity removed in [m/s²]. Used for detecting tapping, walking, and similar actions
TYPE_ROTATION_VECTOR Software Measures the Moverio orientation in rotation vectors. Head tracking and so on

2.4.2 Sensor axis

The Moverio sensors use the same coordinate system as standard Android sensors. When wearing the Moverio, the X axis indicates rightward movement, the Y axis indicates upward movement, and the Z axis indicates the direction toward the user.

2.4.3 Acquiring sensor data

You can use the Moverio SDK to enable use of the various sensors equipped to the Moverio.

To acquire the sensor data, you first need to establish communication with the Moverio sensors. To do this, create a SensorManager class instance and call the open() method. When doing so, pass the listener instances of the sensor types and sensor data as arguments.

*Execute SensorManager#open after confirming that the image is displayed on the Moverio after 10 seconds or more has elapsed since connecting the smartphone with the Moverio via USB.

Otherwise, may not be able to SensorManager#open normally

* When using the Moverio SDK's SensorManager class, import com.epson.moverio.hardware.sensor.SensorManager to avoid name conflict with the Android standard SensorManager class, or set the class name at instance creation to com.epson.moverio.hardware.sensor.SensorManager.

e.g. Import com.epson.moverio.hardware.sensor.SensorManager

import com.epson.moverio.hardware.sensor.SensorManager;

e.g. Create an instance of com.epson.moverio.hardware.sensor.SensorManager

public class SensorActivity extends Activity implements SensorDataListener {
    private com.epson.moverio.hardware.sensor.SensorManager mSensorManager = null;

Sensor data can be acquired at any time necessary by use of the onSensorDataChanged() method for registered listeners. The onSensorDataChanged() method is called at extremely high speed. In order to ensure optimal use of sensors for an application, configure so that processing such as that requiring a great amount of time is not performed within the onSensorDataChanged() method. When you finish acquiring sensor data, make sure you end communication with the Moverio sensors. To end communication, use the close() method.

Sensor data can be obtained as an instance of the SensorData class. For details on the SensorData class, refer to API reference.

public class SensorActivity extends Activity implements SensorDataListener {
    private SensorManager mSensorManager = null;

    @Override
    public final void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mSensorManager = new SensorManager(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        try {
            mSensorManager.open(SensorManager.TYPE_ACCELEROMETER, mSensorDataListener);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        mSensorManager.close();
    }

    @Override
    public void onSensorDataChanged(SensorData data) {
        // Do something with this sensor value.
    }
}

2.4.4 Notes on sensor control

Sensor control using the Moverio SDK can only be used with a single application. When using sensor control with another application, be sure to stop using sensor control with an application that uses sensor control before using it.

2.5. Audio Management

The Moverio can insert earphones conforming to CTIA standard. The Moverio SDK allows you to manage the volume of earphones.

See related information.

Adjusting the volume of earphones

Model Correspondence Table for Audio Management

API Reference

Sample Code

2.5.1. Adjusting the volume of earphones

The Moverio can insert earphones conforming to CTIA standard. The Moverio SDK can increase or decrease the volume of earphones according to the surrounding environment.

To adjust the volume of earphones, you first need to establish communication with the Moverio's audio. To do this, create an instance of the AudioManager class, and then call the open() method.

* When using the Moverio SDK's AudioManager class, import com.epson.moverio.hardware.audio.AudioManager to avoid name conflict with the Android standard AudioManager class, or set the class name at instance creation to com.epson.moverio.hardware.audio.AudioManager.

e.g. import com.epson.moverio.hardware.audio.AudioManager

import com.epson.moverio.hardware.audio.AudioManager;

e.g. Create an instance of com.epson.moverio.hardware.audio.AudioManager

public class AudioActivity extends Activity {
    private com.epson.moverio.hardware.audio.AudioManager mAudioManager = null;

To manually adjust the volume of earphones, use the setVolume() method. See Available volume adjustment range for more information on the available volume adjustment range.

When you have finished adjusting the volume of earphones, make sure you end communication with the Moverio's audio. To end communication, use the close() method.

private AudioManager mAudioManager = new AudioManager(context);
try {
    mAudioManager.open();
} catch (IOException e) {
    e.printStackTrace();
}
mAudioManager.setVolume(12);
mAudioManager.close();

2.5.2. Available volume adjustment range

See following table on the available volume adjustment range.

model volume adjustment range
BT-35E 0 to 15
BT-30C 0 to 20

2.6. Debugging an application over the Network

In application development of USB-connected Moverios such as the BT-35E, you need to connect the Moverio to an Android smartphone by USB to check application operations. Currently, debugging cannot be performed because the computer and Android smartphone are not connected by USB.

As a method of solving the issue above, this section describes how to develop a USB-connected Moverio and an Android smartphone with a USB connection by connecting an ADB to an Android smartphone over the network. See the following websites for more information.
https://developer.android.com/studio/command-line/adb#wireless

  1. Connect the computer and the Android smartphone to the same network.
  2. Connect the computer and the Android smartphone by USB.
    * From here on, Android smartphones connected to the computer are described as singular.
  3. Run the following command on the computer to allow ADB to connect to the Android smartphone over the network.
    # adb tcpip 5555
  4. Disconnect the USB connection between the computer and the Android smartphone.
  5. Check the IP address of the Android smartphone.
    You can check the IP address for most Android smartphones from the settings screen. The method for accessing the screen where the IP address is displayed varies depending on the Android smartphone. For details, check the specific method for your Android smartphone.
  6. Run the following command on the computer to connect to the Android smartphone over the network.
    # adb connect ip_address
    Example: adb connect 192.168.1.10
  7. Execute the following command on the computer to check that the Android smartphone is connected to the computer by ADB.
    Make sure that the connected device is included in the list.
    Check the following points if it is not connected.
    • Are the computer and the Android smartphone connected to the same network?
    • Have you tried connecting again by running the procedure from step 3?
    • Is there an error in the IP address entered in step 6?
    # adb devices
  8. Install the application on the Android smartphone by using Android Studio, and then check the application operations.

2.7. Using the Moverio SDK from Kotlin

The following section explains how to use the Moverio SDK from Kotlin.

Including the Moverio SDK

Sample code for the Moverio SDK API

2.7.1. Including the Moverio SDK

Make sure you include the Moverio SDK into any projects for which Kotlin has been selected as the development language.
See the following for information on including the Moverio SDK.

2.7.2. Sample code for the Moverio SDK API

The following provides sample code for the Moverio SDK API from Kotlin.

2.7.2.1. Display control

Sample code for acquiring and setting the brightness.
See the following for information on display control.

val displayManager = DisplayManager(context)
try {
    displayManager.open()
} catch (e: IOException) {
    e.printStackTrace()
}

val brightness = displayManager.brightness // getBrightness
displayManager.brightness = brightness + 1 // setBrightness

displayManager.close()
2.7.2.2. Sensor control

Sample code for acquiring data for the accelerometer.
See the following for information on sensor control.

class SensorActivity : Activity(), SensorDataListener {

    private var sensorManager: SensorManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        sensorManager = SensorManager(this)
    }

    override fun onResume() {
        super.onResume()
        try {
            sensorManager?.open(SensorManager.TYPE_ACCELEROMETER, this)
        } catch (e: IOException) {
            e.printStackTrace()
        }
    }

    override fun onPause() {
        super.onPause()
        sensorManager?.close(this)
    }

    override fun onSensorDataChanged(SensorData data) {
        // Do something with this sensor value.
    }
}
2.7.2.3. Camera control

Sample code for acquiring a preview.
See the following for information on camera control.

class CameraActivity : Activity() {

    private var cameraManager: CameraManager? = null

    private var cameraDevice: CameraDevice? = null

    private var surfaceView: SurfaceView? = null

    private var captureStateCallback = object : CaptureStateCallback {
        override fun onCaptureStarted() {
            cameraDevice?.startPreview()
        }
                :
                [Omitted]
                :
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.camera)

        surfaceView = findViewById(R.id.surfaceView)
        cameraManager = CameraManager(this)
        try {
            cameraManager?.open(captureStateCallback, null, surfaceView?.holder)
        } catch (e: IOException) {
            e.printStackTrace()
        }
    }

    override fun onResume() {
        super.onResume()
        cameraDevice?.startCapture()
    }

    override fun onPause() {
        super.onPause()
        cameraDevice?.stopPreview()
        cameraDevice?.stopCapture()
    }

    override fun onDestroy() {
        super.onDestroy()
        cameraManager?.close(cameraDevice)
    }
}
Go to Top