SMART DEVICES PROGRAMMING SEMESTER : III CODE : P20CA308 HOURS/WEEK : 4 CREDITS : 3 Core VIII: SMART DEVICES PROGRAMMING UNIT– I Getting Started with Android Programming What is Android? Android is an open source and Linux-based Operating System for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies. Android offers a unified approach to application development for mobile devices which means developers need only develop for Android, and their applications should be able to run on different devices powered by Android. The first beta version of the Android Software Development Kit (SDK) was released by Google in 2007 where as the first commercial version, Android 1.0, was released in September 2008. On June 27, 2012, at the Google I/O conference, Google announced the next Android version, 4.1 Jelly Bean. Jelly Bean is an incremental update, with the primary aim of improving the user interface, both in terms of functionality and performance. The source code for Android is available under free and open source software licenses. Google publishes most of the code under the Apache License version 2.0 and the rest, Linux kernel changes, under the GNU General Public License version 2. 1 SMART DEVICES PROGRAMMING Why Android ? History of Android Version The code names of android ranges from A to N currently, such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwitch, Jelly Bean, KitKat, Lollipop and Marshmallow. Let's understand the android history in a sequence. 2 SMART DEVICES PROGRAMMING The development of the Android operating system was started in 2003 by Android, Inc. Later on, it was purchased by Google in 2005. The beta version of Android OS was released on November 5, 2007, while the software development kit (SDK) was released on November 12, 2007. The first Android mobile was publicly released with Android 1.0 of the T-Mobile G1 (aka HTC Dream) in October 2008. Google announced in August 2019 that they were ending the confectionery scheme, and they use numerical ordering for future Android versions. The first Android version which was released under the numerical order format was Android 10. What is API level? API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform. Code name Version numbers API level Release date No codename 1.0 1 September 23, 2008 No codename 1.1 2 February 9, 2009 Cupcake 1.5 3 April 27, 2009 Donut 1.6 4 September 15, 2009 Eclair 2.0 - 2.1 5-7 Froyo 2.2 - 2.2.3 8 Gingerbread 2.3 - 2.3.7 9 - 10 December 6, 2010 Honeycomb 3.0 - 3.2.6 11 - 13 February 22, 2011 Ice Cream Sandwich 4.0 - 4.0.4 14 - 15 October 18, 2011 Jelly Bean 4.1 - 4.3.1 16 - 18 July 9, 2012 KitKat 4.4 - 4.4.4 19 - 20 October 31, 2013 October 26, 2009 May 20, 2010 3 SMART DEVICES PROGRAMMING Marshmallow 6.0 - 6.0.1 23 October 5, 2015 Nougat 7.0 24 August 22, 2016 Nougat 7.1.0 - 7.1.2 25 October 4, 2016 Oreo 8.0 26 August 21, 2017 Oreo 8.1 27 December 5, 2017 Pie 9.0 28 August 6, 2018 Android 10 10.0 29 September 3, 2019 Android 11 11 30 September 8, 2020 Android Version 1.0 to 1.1: No codename Android officially publish its Android version 1.0 in September 2008. It is the initial version of Android operating system. It supports Web browser to show HTML and XHTML web pages, camera, access web email server (POP3, IMAP4, and SMTP). This version contains Google Calendar, Google Maps, Google Sync, Google Search, Google Talk, Instant messaging, Media player, Notifications appear in the status bar, wallpaper, YouTube video player, Alarm Clock, Calculator, Dialer, Pictures (Gallery), Wi-Fi and Bluetooth support. Android version 1.5: Cupcake On April 27, 2009, the Android updated to 1.5 with the codename of the dessert item (Cupcake). It has Linux kernel 2.6.27. It supports third-party virtual keyboard, Video recording and playback in MPEG-4, Copy and paste feature, Animated screen translations, auto-rotation option, ability to upload a video to YouTube, upload photos to Picasa, check phone usage history. Android version 1.6: Donut On September 15, 2009, Android 1.6 was released with the name Donut. It contains numerous new features such as voice and text entry search, bookmark history, contacts, web, "speak" a string of text, faster camera access, user can select multiple photos for deletion, support text-tospeech engine, WVGA screen resolutions. Android version 2.0 to 2.1: Eclair On October 26, 2009, Android 2.0 was released, whose codename was Eclair. It was based on Linux kernel 2.6.29. It contains the several new features as expanded account sync, Microsoft Exchange email support, Bluetooth 2.1, ability to tap a Contact photo and select to call, SMS, 4 SMART DEVICES PROGRAMMING ability to search all saved SMS, MMS messages, delete the oldest message automatically when the defined limit is reached, Minor API, bug fixes. Android version 2.2 to 2.2.3: Froyo On May 20, 2010, Android 2.2 (Froyo) was released based on Linux kernel 2.6.32. It contains several features as speed, memory, performance optimization. JIT compilation, Integration of Chrome's V8, JavaScript engine into the Browser application, support Android Cloud to Device Messaging service, Adobe Flash support, security updates, and performance improvement. Android version 2.3 to 2.3.7: Gingerbread On December 6, 2010, the Android 2.3 (Gingerbread) was released based on Linux kernel 2.6.35. It includes the following changes: support for extra-large screen size and resolutions, updated user interface design with increased simplicity and speed, enhanced copy/paste functionality, select a word by press-holding, support Near Field Communication (NFC), headphone virtualization, new Download Manager. It has improved bug fixes for Nexus S, voice or video chat using Google Talk, network performance for Nexus S 4G, Gmail application, battery efficiency, fixed a voice search bug, Google Wallet support for Nexus S 4G. Android version 3.0 to 3.2.6: Honeycomb On February 22, 2011, Android 3.0 (Honeycomb) was launched for the first tablet for Androidbased on Linux kernel 2.6.36. It contains the features like "holographic" user interface for tablet, added system Bar, simplified multitasking tapping Recent Application in system Bar, redesign the keyboard making fast typing, quick access to camera exposure, hardware acceleration, support for multi-core processor, UI refinements, connectivity for USB accessories, support for joysticks and gamepads, high-performance Wi-Fi lock, improved hardware support, Google Books, fixed data connectivity issues when coming out of Airplane mode. Android version 4.0 to 4.0.4: Ice Cream Sandwich On October 19, 2011, Android 4.0.1 (Ice Cream Sandwich) was launched, which was based on Linux kernel 3.0.1. It was the last version of officially support Adobe System Flash player. It introduces the numerous new features: refinements to "Holo" interface with new Roboto font family, separation of widgets in a new tab, integrated screenshot capture, improved error correction on the keyboard, improved copy and paste functionality, build-in photo editor, fixed minor bugs, improvement to graphics, spell-checking, better camera performance. Android version 4.1 to 4.3.1: Jelly Bean On June 27, 2012, Google announced Android 4.1(Jelly Bean) in the Google I/O conference. It is based on Linux kernel 3.0.31. It updates to following features: smoother user interface, enhance accessibility, expandable notification, fixed bug on Nexus 7, one-finger gestures to expand/collapse notifications, lock screen improvement, multiple user accounts (tablets only), 5 SMART DEVICES PROGRAMMING new clock application, Bluetooth low energy support, volume for incoming call, 4K resolution support, native emoji support, bug fixes for the Nexus 7 LTE. Android version 4.4 to 4.4.4: KitKat On September 3, 2013, Google announced Android 4.4 (KitKat). Initially, its code name was "Key Lime Pie". Google started on Google's Nexus 5 on October 31, 2013. The minimum required amount of RAM should available to Android is 340 MB. The other devices with less than 512 MB of RAM must report themselves as "low RAM" devices. It includes several new features as clock no longer display bold hours, wireless printing capability, WebViews are based on Chromium engine, sensor batching, built-in screen recording feature, better application compatibility, camera application loads Google+ Photo instead of Gallery. Android version 5.0 to 5.1.1: Lollipop Android 5.0 "Lollipop" was initially named "Android L" on June 25, 2014. It was officially introduced on November 12, 2014. Lollipop provides several features like redesigned user interface, support for 64-bit CPUs, support for print previews, material design, Project Volta for battery life improvement, multiple user accounts, audio input, and output through USB devices, join Wi-Fi networks, support for multiple SIM cards, device protection, high-definition voice calls, native Wi-Fi calling support. Android version 6.0 - 6.0.1: Marshmallow Android 6.0 "Marshmallow" was disclosed under the codename "Android M" on May 28, 2015, for Nexus 5 and Nexus 6 phones, Nexus 9 tablet. On October 5, 2015, Android lunches "Marshmallow" for all android devices. It contains the various new features as App Standby feature, introduce the Doze mode to save battery life, native fingerprint reader support, run-time permission requests, USB-C support, Unicode 7.0 & 8.0 emoji support. Android version 7.0 to 7.1.2: Nougat Android 7.0 "Nougat" was the major release for the Android operating system. Its initial codename was "Android N". It was first released as a developer preview on March 9, 2016, with factory images for the Nexus device. On August 22, 2016, the final preview built was released with following features: file-based encryption, zoom in the screen, multi-window support, new Data Saver mode, JIT compiler makes 75 percent faster app installation, picture-in-picture support, support manager APIs, circular app icons support, send GIFs directly from the default keyboard, battery usage alerts. Android version 8.0 to 8.1: Oreo Android 8.0 "Oreo" was the 8th major release of the Android operating system. It was first released for developer preview on March 21, 2017. The final developer preview was released on July 24, 2017. 6 SMART DEVICES PROGRAMMING On August 21, 2017, its stable version was released with several features: picture-in-picture support, support for Unicode 10.0 emoji (5.0), restructured settings, adoptive icons, notification channels, notification dots, 2 times faster boot time, Google Play Protect, Integrated printing support, Neural network API, shared memory API, Android Oreo Go Edition, autofill framework, automatic light, and dark themes. AD Android version 9.0: Pie Android 9.0 "Pie" was the ninth major version of the Android operating system. It was first announced and preview launched by Google on March 7, 2018. It was officially released on August 6, 2018. It has the following features: the clock has moved to the left of the notification bar, the "screenshot" button has been added, battery percentage always shown on display. Android version 10: Android 10 is the tenth extensive version of the Android operating system. Android 10 has developed under the codename "Android Q". It was initially announced by Google on March 13, 2019 and its first beta version was released on same day and its second beta was released on April 3, 2019. The stable version of Android 10 was released on September 3, 2019. It contains features like new permissions to access location in the background, floating setting panel, support for an AV1 video codec, support for biometric authentication, support the WPA3 Wi-Fi security. Android 11 Android 11 operating system is the eleventh big release of Android. It is the 18th version of Android mobile OS, which was released on 8 September 2020. The alphabetic naming system of Android, based on deserts, was stopped since Android 10. So therefore, this operating system has branded with "Android 11". Features included in Android 11 Conversations: Get all your message in one place. Accessibility: Perceptive apps help us to control and navigate our phone using voice command. Device controls: Android 11 allows us to control all our connected devices (IOT) from a single point. Content capture: Android 11 comes with a screen recording feature that captures our phone's current screen activity. Predictive tools: By predicting our habits and patterns of working, it suggests accordingly. Privacy & security: Android 11 gives more security and privacy fixes to our smartphone straight from Google Play. 7 SMART DEVICES PROGRAMMING Media: We can play music from other devices connected to our phones. Features of Android Android is a powerful operating system competing with Apple 4GS and supports great features. Few of them are listed below − Sr.No. Feature & Description 1 Beautiful UI Android OS basic screen provides a beautiful and intuitive user interface. 2 Connectivity GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and WiMAX. 3 Storage SQLite, a lightweight relational database, is used for data storage purposes. 4 Media support H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP. 5 Messaging SMS and MMS 6 Web browser Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript engine supporting HTML5 and CSS3. 7 Multi-touch Android has native support for multi-touch which was initially made available in handsets such as the HTC Hero. 8 Multi-tasking User can jump from one task to another and same time various application can run simultaneously. 9 Resizable widgets Widgets are resizable, so users can expand them to show more content or shrink them to save space. 10 Multi-Language Supports single direction and bi-directional text. 8 SMART DEVICES PROGRAMMING 11 GCM Google Cloud Messaging (GCM) is a service that lets developers send short message data to their users on Android devices, without needing a proprietary sync solution. 12 Wi-Fi Direct A technology that lets apps discover and pair directly, over a high-bandwidth peer-to-peer connection. 13 Android Beam A popular NFC-based technology that lets users instantly share, just by touching two NFC-enabled phones together. Architecture of Android Android operating system is a stack of software components which is roughly divided into five sections and four main layers as shown below in the architecture diagram. Linux kernel 9 SMART DEVICES PROGRAMMING At the bottom of the layers is Linux - Linux 3.6 with approximately 115 patches. This provides a level of abstraction between the device hardware and it contains all the essential hardware drivers like camera, keypad, display etc. Also, the kernel handles all the things that Linux is really good at such as networking and a vast array of device drivers, which take the pain out of interfacing to peripheral hardware. Libraries On top of Linux kernel there is a set of libraries including open-source Web browser engine WebKit, well known library libc, SQLite database which is a useful repository for storage and sharing of application data, libraries to play and record audio and video, SSL libraries responsible for Internet security etc. Android Libraries This category encompasses those Java-based libraries that are specific to Android development. Examples of libraries in this category include the application framework libraries in addition to those that facilitate user interface building, graphics drawing and database access. A summary of some key core Android libraries available to the Android developer is as follows − android.app − Provides access to the application model and is the cornerstone of all Android applications. android.content − Facilitates content access, publishing and messaging between applications and application components. android.database − Used to access data published by content providers and includes SQLite database management classes. android.opengl − A Java interface to the OpenGL ES 3D graphics rendering API. android.os − Provides applications with access to standard operating system services including messages, system services and inter-process communication. android.text − Used to render and manipulate text on a device display. android.view − The fundamental building blocks of application user interfaces. 10 SMART DEVICES PROGRAMMING android.widget − A rich collection of pre-built user interface components such as buttons, labels, list views, layout managers, radio buttons etc. android.webkit − A set of classes intended to allow web-browsing capabilities to be built into applications. Having covered the Java-based core libraries in the Android runtime, it is now time to turn our attention to the C/C++ based libraries contained in this layer of the Android software stack. Android Runtime This is the third section of the architecture and available on the second layer from the bottom. This section provides a key component called Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed and optimized for Android. The Dalvik VM makes use of Linux core features like memory management and multi-threading, which is intrinsic in the Java language. The Dalvik VM enables every Android application to run in its own process, with its own instance of the Dalvik virtual machine. The Android runtime also provides a set of core libraries which enable Android application developers to write Android applications using standard Java programming language. Application Framework The Application Framework layer provides many higher-level services to applications in the form of Java classes. Application developers are allowed to make use of these services in their applications. The Android framework includes the following key services − Activity Manager − Controls all aspects of the application lifecycle and activity stack. Content Providers − Allows applications to publish and share data with other applications. Resource Manager − Provides access to non-code embedded resources such as strings, color settings and user interface layouts. 11 SMART DEVICES PROGRAMMING Notifications Manager − Allows applications to display alerts and notifications to the user. View System − An extensible set of views used to create application user interfaces. Applications All the Android applications are at the top layer. The applications are to be installed on this layer only. Examples of such applications are Contacts Books, Browser, Games etc. Android Applications Android applications are usually developed in the Java language using the Android Software Development Kit. Once developed, Android applications can be packaged easily and sold out either through a store such as Google Play, SlideME, Opera Mobile Store, Mobango, Fdroid and the Amazon Appstore. Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It's the largest installed base of any mobile platform and growing fast. Every day more than 1 million new Android devices are activated worldwide. This tutorial has been written with an aim to teach you how to develop and package Android application. We will start from environment setup for Android application programming and then drill down to look into various aspects of Android applications. Android Devices in the Market Android devices come in all shapes and sizes. As of late November 2010, the Android OS can be seen powering the following types of devices: Smartphones Tablets E-reader devices Netbooks MP4 players Internet TVs 12 SMART DEVICES PROGRAMMING Chances are good that you own at least one of the preceding devices. The following figure shows (clockwise) the Samsung Galaxy S, the HTC Desire HD, and the LG Optimus One smartphones.Another popular category of devices that manufacturers are rushing out is the tablet. Tablet sizes typically start at seven inches, measured diagonally. The Samsung Galaxy Tab and the Dell Streak, which is a fiveinch phone tablet. Besides smartphones and tablets, Android is also beginning to appear in dedicated devices, such as e-book readers. The Barnes and Noble’s NOOKcolor, which is a color e-Book reader running the Android OS. In addition to these popular mobile devices, Android is also slowly finding its way into the living room. People of Lava, a Swedish company, has developed an Android-based TV, call the Scandinavia Android TV. Google has also ventured into a proprietary smart TV platform based on Android and co-developed with companies such as Intel, Sony, and Logitech. Categories of Android applications There are many android applications in the market. The top categories are − 13 SMART DEVICES PROGRAMMING Obtaining the required Tools (Android - Environment Setup) To start the Android application development on either of the following operating systems − Microsoft Windows XP or later version. Mac OS X 10.5.8 or later version with Intel chip. Linux including GNU C Library 2.7 or later. Second point is that all the required tools to develop Android applications are freely available and can be downloaded from the Web. Following is the list of software's you will need before you start your Android application programming. Java JDK5 or later version Android Studio Here last two components are optional and if you are working on Windows machine then these components make your life easy while doing Java based application development. So let us have a look how to proceed to set required environment. Set-up Java Development Kit (JDK) You can download the latest version of Java JDK from Oracle's Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively. 14 SMART DEVICES PROGRAMMING If you are running Windows and installed the JDK in C:\jdk1.8.0_102, you would have to put the following line in your C:\autoexec.bat file. set PATH=C:\jdk1.8.0_102\bin;%PATH% set JAVA_HOME=C:\jdk1.8.0_102 Alternatively, you could also right-click on My Computer, select Properties, then Advanced, then Environment Variables. Then, you would update the PATH value and press the OK button. On Linux, if the SDK is installed in /usr/local/jdk1.8.0_102 and you use the C shell, you would put the following code into your .cshrc file. setenv PATH /usr/local/jdk1.8.0_102/bin:$PATH setenv JAVA_HOME /usr/local/jdk1.8.0_102 Alternatively, if you use Android studio, then it will know automatically where you have installed your Java. Android IDEs There are so many sophisticated Technologies are available to develop android applications, the familiar technologies, which are predominantly using tools as follows Android Studio Eclipse IDE(Deprecated) Eclipse, Android SDK, Android Development Tools (ADT) and Creating Android Virtual Devices (AVDs) Step 1: Obtain the Android SDK We need to obtain the Android Software Development Kit. To do that we must first visit the SDK download site below. http://developer.android.com/sdk/index.html Scroll to the bottom of the webpage and select the 'Download the SDK Tools' button. This will open a file to be saved somewhere. 15 SMART DEVICES PROGRAMMING Step 2: Install the Android SDK Open the file we just downloaded. This will open an executable which will ask you about the installation process. When you get to the install location screen, make sure you choose a location you remember (we will need it later). 16 SMART DEVICES PROGRAMMING Step 3: Open Android SDK Manager We'll select the most recent version along with the extra SDK tools so you can build applications for any Android version. Open the folder that we installed the SDK into. You'll see a executable called 'SDK Manager'. Open it. You'll see a window where you can select different versions of Android to develop for. Step 4: Install Android Version and Extras for SDK Select the 'Tools' and 'Android 4.4.2 (API 19)' check boxes. If you would like to have extra Android tools you can choose them from the 'Extras' selection. You will then be prompted to accept the Android conditions and then the SDK will install. Then installation may take a while depending on your internet connection. The Android SDK is now completely installed. 17 SMART DEVICES PROGRAMMING Step 5: Obtain Eclipse IDE 18 SMART DEVICES PROGRAMMING Eclipse is the tool we'll be using to develop in. It is the most popular Android development environment and has officially supported tools from Google. Download Eclipse from the website below. http://www.eclipse.org/downloads/packages/eclipse-... Find the link for your operating system and 32/64 bit version. Save the compressed download file. Step 6: Run Eclipse for First Time Eclipse does not require installation. It's a folder with all the necessary files and settings. You can run it directly from the Eclipse folder. It's recommended you put it in a safe place with other applications. Extract the downloaded Eclipse file into a safe place where you can keep the program. Open the extracted folder and open the 'eclipse' executable. You should see a screen similar to the one attached if all went well. 19 SMART DEVICES PROGRAMMING Step 7: Add ADT Plugin Repository The ADT (Android Development Tool) Plugin was made specifically for Eclipse to increase productivity and integration with your Android work environment. To use it, we first add the Eclipse plugin repository so it knows where to find it along with updates. In the Eclipse application menu, go to 'Help' and then 'Install New Software'. Click on the 'Add...' button and you'll see a window appear. Give the repository a name like 'ADT Repo'. Give it the location http://dl-ssl.google.com/android/eclipse/. Click 'OK' button. 20 SMART DEVICES PROGRAMMING Step 8: Install ADT Plugin Now that we have the plugin repo setup we need to install the plugin from it. On the 'Install Software' screen, select the repo you just created from the 'Work with' selector. Select the 'Developer Tools' option from the listed below options. Click 'Next' and accept the agreements. Click 'Finish' and let it install. It might take a while depending on your internet speed. 21 SMART DEVICES PROGRAMMING Step 9: Access ADT Plugin Preferences You'll most likely have to restart Eclipse after you install the ADT Plugin so do that before you continue. Mac/Linux: After Eclipse has restarted, click 'Eclipse' in the application menu. Windows: After Eclipse has restarted, click 'Window' in the application menu. Then select 'Preferences'. In the Preferences window, select the Android tab on the left side and it's corresponding drop down menu. This is the ADT Preferences screen. It will allow you to change setting, remove the SDK and make editor preferences for your development. 22 SMART DEVICES PROGRAMMING Step 10: Setup ADT Plugin Click 'Browse' on the right side of the screen. Search for the folder in which you installed the Android SDK into and select it. Hit the 'Apply' button on the Preferences screen. You should see the Android version you installed early to show up if all went well. If not, try reselecting the folder. (Make sure the folder contains the folders 'buildtools','platform','extras' and etc. Hit the 'OK' button and restart Eclipse. 23 SMART DEVICES PROGRAMMING Step 11: Access ADT Android Virtual Device Manager To test your application we need to add an Android Virtual Device if you don't have a personal device. In the application menu, select 'Window' and then 'Android Virtual Device Manager' Here you can create new 'Devices'. 24 SMART DEVICES PROGRAMMING Step 12: Add ADT Virtual Device Click the 'New...' button on the right side. Give your device a name in 'AVD Name'. You want to check mark 'Use Host GPU' The other options are up to you and can be played with to figure out what works best. When done, hit 'OK'. You have now setup an environment ready to develop Android applications. We installed the Android SDK, Eclipse, and the ADT Plugin. Creating Android Applications You have now setup an environment ready to develop Android applications. Install the Android SDK, Eclipse, and the ADT Plugin. STEP 1: Using Eclipse, create a new project by selecting File → Project 25 SMART DEVICES PROGRAMMING Step 2: Expand the Android folder and select Android Application Project Step 3: Name the Android project as shown in Figure and then click Finish. 26 SMART DEVICES PROGRAMMING Step 4: The Eclipse IDE should now look like Figure. 27 SMART DEVICES PROGRAMMING Step 5: In the Package Explorer (located on the left of the Eclipse IDE), expand the FirstApp project by clicking on the various arrows displayed to the left of each item in the project. In the res/layout folder, double-click the activity_first_main.xml file. Step 6: The activity_first_main.xml file defines the user interface (UI) of your application. The default view is the Layout view, which lays out the activity graphically. To modify the UI, click the activity_first_main.xml tab located at the bottom as in the Figure. Step 7: Add the following code in bold to the activity_first_main.xml file: <?xml version=”1.0” <LinearLayout encoding=”utf-8”?> xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”@string/hello” /> <TextView 28 SMART DEVICES PROGRAMMING android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”This is my first Android Application!” /> <Button android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:text=”And this is a clickable button!” /> </LinearLayout> Step 8: To save the changes made to your project, press Ctrl+s. Step 9: You are now ready to test your application on the Android Emulator. Select the project name in Eclipse. You will be asked to select a way to debug the application. Select Android Application as shown in Figure and click OK. 29 SMART DEVICES PROGRAMMING Difference between Android SDK and Studio Android SDK is a "Software Development Kit" which can integrated with stand alone IDE (Eg. Eclipse) , for Android Development. Whereas Android Studio is a dedicated IDE for Android Development. It comes with Android SDK integrated to it. This (stable version) was only launched end of last year, earlier the alternative was to use Android SDK with Eclipse. Android Studio is a software package not unlike many others on your machine. Click an icon, launch it, mess with the interface, drag things around, make stuff. The Android SDK is a collection of files that live on your computer and are generally only messed with by super-nerds. Use the Android SDK (through a command line program call the adb) all the time. It's nerdy but major powerful. Example: Today to flash a new third party version of Android on a cheapo tablet. Command line work for sure. Android Studio would never do this. But, the Android SDK is well suited to tasks exactly like that. Android Studio, and Eclipse, and all sorts of other "pretty front ends" are nothing more than a collection of buttons, screens, controls and tools that make it "easier" to use the underlying Android SDK that must exist on your machine for them to work. What is Android Studio and Android SDK tools? Android Software Development Kit (SDK) is a toolset that enables developers to create apps for Android OS. It includes the required libraries to build Android apps, a debugger, an emulator, Application Programming Interfaces (APIs) and sample projects with source code, so you can have everything you need to start making your own apps. Important commandline tools for Android app development are grouped into three packages: the already mentioned SDK tools, Platform tools and the Android Emulator. Android SDK tools SDK tools are platform-independent and are required to create any Android app, regardless the version you are developing for. Some of these include: Build tools, Debugging tools and Image tools, among others. Now, some of the most important SDK tools are Android SDK Manager, which provides you resources, platforms and other useful components needed to build apps and manage SDK packages. The Android Virtual Device Manager, that provides a graphical user interface to test your app on a virtual device. The Dalvik Debug Monitor Server (ddms) to debug your Android apps. Or the Draw 9-patch, which allows you to create resizable bitmap images for your app. 30 SMART DEVICES PROGRAMMING Platform tools Platform tools are customized and used to support new features of Android´s latest version, but also compatible with prior versions. Some of these tools include: Android Debug Bridge, Fastboot or Systrace. For instance, Android Debug Bridge (adb) needs to know how to communicate with the Android version hosted on your device, for that it needs the platform-tool component; adb can also be used to install an Android application file on a device. Besides, additional shell tools can be accessed through adb, like bmgr and logcat. Platform tools work along with Build tools for encryption, security and file size purposes. Android Emulator The Android Emulator lets you develop and test your apps without using any physical device. This package is frequently updated and needed to use the Android Emulator Graphic User Interface (GUI) in Android Studio. This enables Android app developers to debug and test their apps in a run-time environment. Android Studio Now, in order to properly run this set of tools you’ll need an Integrated Development Environment (IDE). For Android, that IDE is called Android Studio as mentioned in a prior post: 5 Essential Android Development Tools, allowing you to compile and edit your code, or test your app before releasing it on Google Play. This way, Android Studio allows you to improve your app performance with instant visualization, smart code editor, a fast emulator and a unified environment to help you build apps for all Android devices. According to Android Studio creators and developers users, this IDE was built to make the development process as easy as possible, helping to improve the app development work by making it faster, smarter and more enjoyable. 31