Android Tutorial

Android Tutorial Android Toast Button Widget In Android Tutorial Imageview Widget In Android Android Date Picker Example Android Time Picker Example Android Operating System Android Activity Android Architecture Android Content Providers Android Edittext Android Emulator Android Fragments Android Gridview Android Broadcast Receivers Event Handling In Android What Is Android Studio Android Navigation Drawer Android Recyclerview Android Scrollview Android Navigation Android Operating System Android ListView Android Studio Resources Android Studio's Layout Editor Android TextView Android Styles and Themes How To Show Image On An Android Application How To Insert An Email In Android Application In Android Version 8 How To Insert The Mobile Number On An Android Application Using Edittext Difference between android developer and web AdapterViewFlipper in Android with Example Android 9.0 Pie vs. Android 10, which one is better Android Development or Web Development which one is the best to choose Android Project Folder Structure Assets folder in Android How to reduce the size of APK in Android Top 7 Android App Development Books Top Programming Languages for Android Development Android Navigation Application Components Difference between android developer and web developer Event Handling in Android How to reduce the size of APK in Android Top 7 Android App Development Books Top Programming Languages for Android Development AdapterViewFlipper in Android with Example Android 9.0 “Pie” vs. Android 10, which one is better Android Development or Web Development which one is the best to choose Android EditText Android Fragments How to Update Gradle in Android Studio Navigation Drawer ScrollView What is Android Studio? Android Architecture Android Content Providers

Android Emulator

A tool for creating Android virtual devices (including software and virtual hardware) on your personal desktop is known as Emulator. We can use these virtual devices as the target device to run and test our Android applications on our computer. The Android emulator has almost all the functions of a real device.

We can answer incoming calls and reply to text messages. It can also locate devices and simulate different network speeds such as 4G LTE, WCDMA, GSM. The Android emulator can simulate rotation and features other hardware sensors like GPS, proximity sensor, Gyro-meter, etc. We can also utilize the Google Play store, etc.

Android Emulator

Testing and Debugging Android applications on the virtual device are often quicker and easier than doing on a real device. This is due to the reason that you can transfer data much quickly to the virtual device than to a real device connected through USB or any other means.

A lot of predefined configurations for several Android devices such as phones, smart TV comes along with the Android Emulator.

Hardware Prerequisites

You need SDK version 26.1.1 or higher and a PC/laptop with a 64-bit or 86-bit processor for using the Android emulator. If you want to run your virtual device onthe Android 8.1 versionor higher, you need a webcam that can capture 720p resolution video.

To improve the performance of the virtual device you might need to turn on hardware acceleration in system boot settings. To do this, you need HAXM version7.2.0, which is an Intel hypervisor.

Windows and Linux users need more components, depending on the processor family:

  • Intel: Supports Intel VTx and Intel EM64T (Intel 64); performs bit deactivation (XD).
  • AMD: Android Studio v3.2 or higher; support AMD virtualization (AMD-V); SIMD extension set; Windows hypervisor platform API.

Installing the Emulator

The Android emulator is installed when the Android Studio installation happens. However, some emulator components might not be downloaded or installed during the Android Studio installation.By selecting the Android emulator component on the software development kitTools tab of the SDK Manageryou can install the other emulator components required.

Run an Application on Emulator

To launch the Android Emulator and run an application:

1.  In Android Studio, we must create an Android Virtual Device (AVD) using the inbuilt AVD Manager that the emulator can use to run your android application. Follow the below mentioned steps for creating an Android Virtual Device:

  • By clicking onthe AVD Managericon on the Navigation bar you can open the Android Virtual Device Manager.
Android Emulator
  • At the bottom left of the AVD Manager, Click on Create Virtual Device option. Then Select Hardware windowwill appear.
Android Emulator
  • Select a hardware profile as per your requirement and then click on the Nextbutton. If you are unable to find the hardware profile youneed, then you can make a new or import a hardware profile. After this, The System Image window will appear.
Android Emulator
  • Now select a system image from the given table according to your need and then click on the Next button. After this, a Verify Configuration window opens.
Android Emulator
  • Change Android Virtual Device properties if needed, and then click on the Finishbutton.

2. In the navigation bar, select the Android Virtual Device on which you want to run your android application from the drop-down menu.

Android Emulator

3. At last, ClickRun.

Launch the Emulator using command Line

Using the emulator command, we canlaunch an emulator. It is an alternative way to run our android application or launch through the AVD Manager.

The basic command-line syntax for launching a virtual device is as follows:

$ emulator -avd Pixel_2_API_28 [ {-option [value]} ... ]  

or

$ emulator @ Pixel_2_API_28[ {-option [value]} ... ]  

Ifyou want tolaunch the emulator from Android Studio on a Mac operating system, the default command line will be as follows:

$ /Users/user_name/Library/Android/sdk/emulator/emulator -avd Pixel_2_API_28 -netdelay none -netspeed full  

To display the list of AVD names, enter the following command:

$ emulator -list-avds  

Stop an emulator and Clear the Data

From the Android Virtual Device Managerwindow, we can control the emulator as follows:

Android Emulator
  • To launch an Android emulator using AVD manager, double-click the Virtual device, or click on the Launch icon.
  • To stop the running emulator, right-click the Virtual device and select Stop option or click the Menu and then select Stop option.
  • If you want to delete the data and cache from an emulator and return it to the new state, then right-click a device and select Wipe Data. Or click the menu and then select the Wipe Dataoption.