{"id":265,"date":"2023-05-16T12:47:52","date_gmt":"2023-05-16T12:47:52","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=265"},"modified":"2023-05-16T12:47:52","modified_gmt":"2023-05-16T12:47:52","slug":"1-5-android-emulator-working-with-androidmanifest-xml","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/16\/1-5-android-emulator-working-with-androidmanifest-xml\/","title":{"rendered":"1.5 Android emulator, working with AndroidManifest.xml"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Android Emulator<\/strong><\/h2>\n\n\n\n<p>The Android emulator is an Android Virtual Device (AVD), which represents a specific Android device. We can use the Android emulator as a target device to execute and test our Android application on our PC.&nbsp;<\/p>\n\n\n\n<p>The Android emulator provides almost all the functionality of a real device. We can get incoming phone calls and text messages. It also gives the location of the device and simulates different network speeds.&nbsp;<\/p>\n\n\n\n<p>Android emulator simulates rotation and other hardware sensors. It accesses the Google Play store, and much more<\/p>\n\n\n\n<p>Testing Android applications on emulators is sometimes faster and easier than doing on a real device. For example, we can transfer data faster to the emulator than to a real device connected through USB.<\/p>\n\n\n\n<p>The Android emulator comes with predefined configurations for several Android phones, Wear OS, tablet, Android TV devices.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Requirement and recommendations<\/strong><\/h3>\n\n\n\n<p>The Android emulator takes additional requirements beyond the basic system requirement for Android Studio. These requirements are given below:<\/p>\n\n\n\n<ul>\n<li>SDK Tools 26.1.1 or higher<\/li>\n\n\n\n<li>64-bit processor<\/li>\n\n\n\n<li>Windows: CPU with UG (unrestricted guest) support<\/li>\n\n\n\n<li>HAXM 6.2.1 or later (recommended HAXM 7.2.0 or later)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Install the emulator<\/strong><\/h3>\n\n\n\n<p>The Android emulator is installed while installing the Android Studio. However some components of the emulator may or may not be installed while installing Android Studio.&nbsp;<\/p>\n\n\n\n<p>To install the emulator component, select the Android Emulator component in the SDK Tools tab of the SDK Manager.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Run an Android app on the Emulator<\/strong><\/h3>\n\n\n\n<p>We can run an Android app from the Android Studio project, or we can run an app which is installed on the Android Emulator as we run any app on a device.<\/p>\n\n\n\n<p>To start the Android Emulator and run an application in our project:<\/p>\n\n\n\n<p>1. In Android Studio, we need to create an Android Virtual Device (AVD) that the emulator can use to install and run your app. To create a new AVD:-<\/p>\n\n\n\n<p>1.1 Open the AVD Manager by clicking Tools &gt; AVD Manager.<\/p>\n\n\n\n<p>1.2 Click on Create Virtual Device, at the bottom of the AVD Manager dialog. Then the Select Hardware page appears.<\/p>\n\n\n\n<p>1.3 Select a hardware profile and then click Next. If we don&#8217;t see the hardware profile we want, then we can create or import a hardware profile. The System Image page appears.<\/p>\n\n\n\n<p>1.4 Select the system image for the particular API level and click Next. This leads to opening a Verify Configuration page.<\/p>\n\n\n\n<p>1.5 Change AVD properties if needed, and then click Finish.<\/p>\n\n\n\n<p>2. In the toolbar, choose the AVD, which we want to run our app from the target device from the drop-down menu.<\/p>\n\n\n\n<p>3. Click Run.<\/p>\n\n\n\n<p><strong>Working with AndroidManifest.xml<\/strong><\/p>\n\n\n\n<p>The AndroidManifest.xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.<\/p>\n\n\n\n<p>It performs some other tasks also:<\/p>\n\n\n\n<ul>\n<li>It is responsible to protect the application to access any protected parts by providing the permissions.<\/li>\n\n\n\n<li>It also declares the android api that the application is going to use.<\/li>\n\n\n\n<li>It lists the instrumentation classes. The instrumentation classes provide profiling and other information. This information is removed just before the application is published etc.<\/li>\n<\/ul>\n\n\n\n<p>This is the required xml file for all the android applications and located inside the root directory.<\/p>\n\n\n\n<p><strong>A simple AndroidManifest.xml file looks like this:<\/strong><\/p>\n\n\n\n<p>&lt;manifest xmlns:android=&#8221;http:\/\/schemas.android.com\/apk\/res\/android&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;package=&#8221;com.javatpoint.hello&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;android:versionCode=&#8221;1&#8243;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;android:versionName=&#8221;1.0&#8243; &gt;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;uses-sdk&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:minSdkVersion=&#8221;8&#8243;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:targetSdkVersion=&#8221;15&#8243; \/&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;application&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:icon=&#8221;@drawable\/ic_launcher&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:label=&#8221;@string\/app_name&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:theme=&#8221;@style\/AppTheme&#8221; &gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;activity&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name=&#8221;.MainActivity&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:label=&#8221;@string\/title_activity_main&#8221; &gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;intent-filter&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;action android:name=&#8221;android.intent.action.MAIN&#8221; \/&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;category android:name=&#8221;android.intent.category.LAUNCHER&#8221; \/&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/intent-filter&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/activity&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/application&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&lt;\/manifest&gt;<\/p>\n\n\n\n<p><strong>Elements of the AndroidManifest.xml file<\/strong><\/p>\n\n\n\n<p>The elements used in the above xml file are described below.<\/p>\n\n\n\n<p><strong>&lt;manifest&gt;<\/strong><\/p>\n\n\n\n<p>manifest is the root element of the AndroidManifest.xml file. It has a package attribute that describes the package name of the activity class.<\/p>\n\n\n\n<p><strong>&lt;application&gt;<\/strong><\/p>\n\n\n\n<p>application is the subelement of the manifest. It includes the namespace declaration. This element contains several sub elements that declares the application component such as activity etc.<\/p>\n\n\n\n<p>The commonly used attributes of this element are icon, label, theme etc.<\/p>\n\n\n\n<p><strong>android:icon<\/strong> represents the icon for all the android application components.<\/p>\n\n\n\n<p><strong>android:label<\/strong> works as the default label for all the application components.<\/p>\n\n\n\n<p><strong>android:theme<\/strong> represents a common theme for all the android activities.<\/p>\n\n\n\n<p><strong>&lt;activity&gt;<\/strong><\/p>\n\n\n\n<p>activity is the subelement of application and represents an activity that must be defined in the AndroidManifest.xml file. It has many attributes such as label, name, theme, launchMode etc.<\/p>\n\n\n\n<p><strong>android:label<\/strong> represents a label i.e. displayed on the screen.<\/p>\n\n\n\n<p><strong>android:name<\/strong> represents a name for the activity class. It is a required attribute.<\/p>\n\n\n\n<p><strong>&lt;intent-filter&gt;<\/strong><\/p>\n\n\n\n<p>intent-filter is the sub-element of activity that describes the type of intent to which activity, service or broadcast receiver can respond to.<\/p>\n\n\n\n<p><strong>&lt;action&gt;<\/strong><\/p>\n\n\n\n<p>It adds an action for the intent-filter. The intent-filter must have at least one action element.<\/p>\n\n\n\n<p><strong>&lt;category&gt;<\/strong><\/p>\n\n\n\n<p>It adds a category name to an intent-filter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android Emulator The Android emulator is an Android Virtual Device (AVD), which represents a specific&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/265"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/265\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}