目录

Using Extended Features

The Emulator supports extended capabilities such as battery, GPS, and virtual sensors. For specific usage instructions, refer to the following description. Click on the menu bar of the emulator to open the extensions menu.

Battery Emulation

The Emulator supports emulation of various battery states. On the extensions menu of an emulator, click to open the battery emulation page. On this page, you can manually enter a value or drag the slider to change the battery percentage. You can also click to switch the battery between charging and discharging states. The battery has the following three charging states:

In your app, the @ohos.batteryInfo module can be used to query the remaining battery level and charging state of the emulator.

GPS Positioning

The emulator supports the device location emulation. You can open the extensions menu and click to set the location. The emulator supports the following modes:

In the app, you can obtain the location information of the emulator through the @ohos.geoLocationManager module.

Virtual Sensor

The emulator provides virtual sensors to emulate the capabilities of hardware sensors. Click on the extension menu to open the Activate Virtual sensor emulation page. On this page, you can adjust different sensors to test your app and use the @ohos.sensor module to monitor changes of sensor values. The emulator provides the following virtual sensors:

You can adjust values by dragging the sliders or entering them directly into the text boxes.

Network

The network function of the emulator allows you to configure proxy servers and DNS addresses. Open the extensions menu and click to open the network settings page.

The proxy and DNS settings cannot be enabled simultaneously.

Proxy settings

The emulator can proxy network requests to a proxy server, which then forwards requests to the target server. In this way, the following development scenarios are met:

The emulator provides the following proxy modes:

After configuring the proxy, you can click Check Connection to verify the current proxy configuration and click Apply to save the configuration. When HTTPS requests are sent, you need to install the website's digital certificate. For details, see How do I install a digital certificate for initiating HTTPS requests.

DNS settings

Since DevEco Studio 6.1.0 Beta2, the DNS settings function has been added, allowing you to manually configure DNS servers for domain name resolution. Click Apply to save the settings.

Shake

The emulator can emulate the Shake operation performed by the user on the device. Click on the toolbar to emulate a 1-second shake. Your app can listen for changes in the accelerometer via the @ohos.sensor module. When the acceleration variation reaches the preset threshold, the service logic for the Shake feature is triggered.

Currently, Shake is available only on phones and tablets.

Audio Input

The Emulator supports audio input capabilities provided by Audio Kit. You can use the microphone on your local computer to transmit audio data to an emulator. Procedure:

  1. Ensure that the local computer is connected to a microphone.
  2. Have your app call the APIs (such as AudioCapturer and OHAudio) provided by Audio Kit to start receiving audio data.
  3. Use the local microphone for audio input.

When the app on the emulator calls related APIs, the audio stream information in the following table is recommended to ensure clear and smooth audio quality.

Audio Stream Information

Recommended Configuration

samplingRate

48000 Hz

channels

2

sampleFormat

Signed 16-bit integer

encodingType

PCM encoding

Camera

Since DevEco Studio 5.1.0 Release, the emulator supports the use of the local computer's camera. For example, by calling the APIs provided by Camera Kit, you can implement photo capture and camera preview on emulators. Using Scan Kit, you can implement barcode/QR code scanning on emulators running API version 20 or later. For other Kits that depend on camera capabilities, refer to the emulator support information in their respective Kit introductions.

The development steps for using the camera on the emulator are as follows:

  1. Ensure that there is an available camera on the local computer. Since version 26.0.0, external USB cameras are supported, but only 720p cameras are supported.
  2. The app calls the relevant APIs provided by the corresponding kits to implement functions such as preview, photo capture, and code scanning using the computer-hosted camera.
  • When developing camera features using an emulator, use the following camera configuration: RGBA_8888 format and 1280 × 720 resolution.
  • In external USB camera scenarios, if the USB camera is plugged or unplugged during use, you need to clear the app data and restart the app in the emulator for the USB camera to be recognized again.

For camera-less scenarios, the Emulator supports the virtual camera feature since version 26.0.0. By loading the preset image as the camera input source, you can fully simulate the camera capture pipeline in camera-less environments, completing camera-related app development and debugging.

  1. Click on the extensions menu of the emulator to open the Virtual Camera Setting page. Upload an image that meets the specifications as the preset image. The uploaded image will be cropped to 720p. For image upload specifications, refer to the on-screen prompts.
  2. Call the camera capture API in your app. When the camera is launched, the camera preview displays the preset image. Perform a capture. The app retrieves the preset image and saves it to the specified output path.

Crown

The wearable emulator can emulate the crown functionalities.

Settings

The Emulator supports theme and language settings, as well as configuration of the screenshot save path. Open the extensions menu and click to open the settings panel.

Multi-Screen

Since DevEco Studio 6.0.0 Beta1, the Emulator supports the multi-screen mode. This allows you to create multi-screen emulators with different screen resolutions and DPIs from a single base image, facilitating rapid testing of UI layouts and other elements across different screen configurations.

[h2]Constraints

[h2]Adding a Screen

  1. Start the emulator and click in the toolbar to open the multi-screen management UI.

  2. Click Add, select a product model (such as Mate series, Pura series, and nova series), and click Apply to add the corresponding screen.

    By default, all screens are dragged and scaled together as a group. To drag and scale individual screens separately, check the option Secondary displays are shown in separate windows on the UI and click Apply. This feature is supported since DevEco Studio 6.0.1 Beta1.

  3. To start an app simultaneously on multiple screens, set launchType in module.json5 to multiton as prompted. For details, see UIAbility Launch Type.

[h2]Modifying Screen Parameters

To customize the screen resolution, DPI, or size, you can modify the screen parameters on the multi-screen UI (valid ranges are provided as prompts) and click Apply.

[h2]Using a Secondary Screen

[h2]Deleting a Screen

Click on the multi-screen UI, and click Apply to delete a screen.

[h2]Multi-Screen Capability of Telematics Device Emulators

Since version 26.0.0, telematics device emulators support the multi-screen capability. By adding a secondary screen, you can simulate scenarios with a cockpit main display and a front passenger display.

When creating a telematics device emulator, you can add or delete screens. For details, see Creating an Emulator. After a screen is added, the secondary screen is automatically displayed when the emulator is started.

Each screen of the telematics device emulator corresponds to an independent user. Operations on the main and secondary screens are independent of each other. For example, app installation, debugging, and uninstallation must be performed independently on each screen.

After adding a screen, if you do not need to show the secondary screen during usage, click the multi-screen button on the emulator toolbar, clear the checkbox for the corresponding screen, and click Apply.

The telematics device emulator supports two layout modes: page-style stacked layout and tiled layout. Switch between them via the multi-screen button on the toolbar, and click Apply.