Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Android Application Development with Java SCSR 3243 (NetCentric Computing) 2014/15-2 Mohd Soperi [email protected] Overview What is Android? Android Milestones Android Application Development Application Components Hello, Android Basic Android graphics Part 2: More Android! What is Android? What is Android? An open source Linux-based operating system, created by Google specifically for use on mobile computing platforms Can be programmed in C/ C++ but most application development is done in Java (Java access to C Libraries via JNI (Java Native Interface)) Supports Bluetooth, Wi-Fi, 3G, 4G, … networking Commonly Used Packages • • • • User interface controls and widgets User interface layout Secure networking and web browsing Structured storage and relational databases (SQLite RDBMS) • 2D and 3D Graphics SGL and OpenGL • Audio and visual media support • Access to optional hardware (GPS) Android Milestones • October 2003, Android Inc. founded • August 2005, Google acquires Android Inc. • 5 November 2007, Open Handset Alliance (OHA) formed. Android unveiled • 12 November 2007, Android Beta SDK released Android Milestone Android version 1.0 G1 SDK release* Notable updates February 2008 • GPS and Bluetooth (but not stereo Bluetooth) • Multitasking • Tight integration with Google services like Gmail, Google Maps (with Street View), and Google Calendar • Apps: Amazon MP3 Store; YouTube • Android Market (about 35 apps at launch) • No Microsoft Exchange Server; no camcorder Android Milestone Android version 1.5 Cupcake SDK release* April 2009 Notable updates • Universal search box (search had been limited to the Web) • Revamped Android Market: Browsing categories (Apps, Games, Downloads) and filters (Top Free, Top Paid, Just In) • Camera: Toggle between camera and video modes; integrated photo gallery and camera with bulk photo deleting • SDK expands support for gestures, voice-to-text Android Milestone Android version 1.6 Donut SDK release* Notable updates September 2009 • Virtual onscreen keyboard • Camcorder mode for recording (and watching) video • Stereo Bluetooth • Home screen widgets and folders • Copy/paste and search within the browser • Direct upload to YouTube and Picasa Android Milestone Android version 2.0 Eclair SDK release* October 2009 Notable updates • Multiple user accounts • Exchange support; universal email inbox • Quick Contact pop-up widget to launch communications with friends in the address book • Search saved SMS and MMS messages • Camera improvements include support for flash and digital zoom • Bluetooth 2.1 • Keyboard improvements: Adaptive dictionary that includes contact names in suggestions Android Milestone Android version 2.1 Eclair 2.2 Froyo SDK release* January 2010 May 2010 Notable updates • Live wallpaper; five home screens • Speech-to-text added to any text field; microphone icon for voice dictation in emails, texts, and so on • Speedier OS • USB tethering and hotspot support • Android Market update: Batch and automatic updates; installing apps to the SD card • Adobe Flash 10.1 • File uploading in the browser • Improved Microsoft Exchange support: Security policies, global address lookup, calendar sync, remote wipe • Bluetooth support for voice dialing and contact sharing Android Milestone Android version 2.3 Gingerbread 3.0 Honeycomb SDK release* Notable updates December 2010 • • • • • Redesigned copy/paste WebM video compression support NFC (near-field communication) support Switch to front-facing camera from camera app Virtual keyboard shortcuts February 2011 • • • • • • • 3D graphics support Side-by-side browser tabs; private browsing Dual-pane modes for address book, email Redesigned UI includes program thumbnails Video chatting with Google Talk Full-screen-mode photo gallery Bluetooth tethering Android Milestone Android version 3.1 – 3.2.6 Honeycomb SDK release* Notable updates May 2011 – February 2012 • Support for peripherals like keyboards and game pads • Resizable widgets • "Pay as you go" support for 3G, 4G tablets • Various bug fixes and enhancements Android Milestone Android version SDK release* Notable updates • • • • • • 4.0 Ice Cream Sandwich October 2011 • • • • • • • • • • • • • • • • • • Support for virtual buttons in addition to touch-sensitive buttons Create folders by dragging apps on top of each other A new app tray tab for thumbing through widgets Calendar app now supports pinch-to-zoom Gmail gets new design, offline search, swiping between conversations New Chrome browser syncs with your bookmarks, saves pages offline, supports 16 browser tabs More keyboard error correction, inline spell check Customizable lock screen, launcher Recent applications icon Roboto typeface New swipe/delete behavior Improved voice integration and copy and paste Face Unlock security feature Data Usage tracking Hide unwanted app icons Shut down apps that are using background data Native camera features include zero shutter lag, continuous focus, zoom while recording, taking a still photo while recording, panorama photos, time lapse settings, 1080p recording Face detection in the cameraIntegrated photo editor New gallery layout, organized by location and person Phone app lets you swipe between favorite friends with integrated visual voice mail Speed up and slow down voice mails Quick message sends canned response text message when you decline a call Android Beam, an NFC feature for exchanging information between two phones by tapping them Wi-Fi Direct support Android Milestone Android version 4.1 Jelly SDK release* July 2012 Notable updates • • • • • • • • • • • • • • • • Faster, smoother performance with "Project Butter" Expandable notifications with greater interaction Voice search access by swiping up from bottom of the screen Voice actions engine replies to some queries Google Now Offline dictation Default Chrome browser Resizable app widgets Android Beam support for transferring larger files, like photo and video New filmstrip view of recent shots in the camera app Applications update in Google Play with just the changed code Sound search widget for music ID Higher-resolution contact photos Greater accessibility options Expanded language support, especially for Arabic and Hebrew Interface tweaks Android Milestone Android version SDK release* Notable updates • • • 4.2 – 4.3 Jelly Bean November 2012 – October 2013 • • • • • • • • Lock screen widgets, and the ability to open the camera from the lock screen Quick Settings in the notification menu to toggle Wi-Fi or Bluetooth and more "Daydream" screensavers, which show time and other information when the screen is locked or device is docked Multiple user accounts on tablets only Support for wireless display (such as Miracast) Accessibility features, including triple-tap to magnify the entire screen, pan and zoom with two fingers, speech output for blind users Unified interface layout for all devices, with system bar at the top of the screen, and a home screen dock More Actionable Notifications, which let you respond to the notification without opening the app Bluetooth Low Energy support Location tracking with Wi-Fi -- your device can track your location without turning on Wi-Fi Support for 4K resolution phones Android Milestone Android version 4.4 KitKat SDK release* October 2013 Notable updates • Major design interface update, especially for new Nexus devices • Translucent status bar in the OS and in apps • New "immersive mode" where apps can hide navigation and status bars • The size of the operating system shrunk so it can run on lower-end devices with small amounts of RAM and internal storage • Wireless printing using Google Cloud Print Android Milestone Android version 5.0 Lollipop SDK release* October 2014 Notable updates • Completely redesigned UI called Material • Notifications on the lock screen and new pop-up alerts • Priority mode silences less important notifications • Multiple user accounts for both phones and tablets • New recent apps menu called Overview • Guest mode • Screen pinning • Battery Saver mode • Default device encryption • Smart lock unlocks devices with Bluetooth device or NFC tag Distribution of Devices Version Codename API Distribution Jelly Bean 2.2 Froyo 8 0.3% 2.3.3 2.3.7 Gingerbread 10 5.7% 4.0.3 4.0.4 Ice Cream Sandwich 15 5.3% 4.1.x Jelly Bean 16 15.6% 4.2.x 17 18.1% 4.3 18 5.5% Android 4.1.1 Android 4.0+ Gingerbread 4.4 KitKat 19 39.8% 5.0 Lollipop 21 9.0% 22 0.7% 5.1 Ice cream Sandwich http://developer.android.com/resources/dashboard/platform-versions.htm Data Collected during a 7-day period ending on May 4, 2015 Android 2.3 Android Application Development Eclipse IDE/ Android Studio Android SDK Android Emulator Android Mobile Device Writing Android App using Java No public static void main() method Closer in spirit to servlet approach Create subclasses of some Android-supplied base classes that define various application components Create some metadata to tell Android about those subclasses Android App Components Activities – building block of user interface, analogue for window or dialog in a desktop application, or the page in a classic Web app Services – keep running independent of any activity for a moderate period of time (e.g. checking for updates to RSS feed, play back music even if the controlling activity is no lenger operating) Activity FIGURE 3.2 Important callback methods of the activity life cycle. Copyright ©2010 Lauren Darcey and Shane Conder Android App Components Content Providers – to make your own data available to yourself and other applications Broadcast Receivers – arrange application to listen for broadcasts (e.g. battery getting low, screen turns off, connectivity changes from WiFi to mobile data, etc) Widgets, Containers, Resources, Fragments Most activities use “widget framework” for rendering their user interfaces, although 2D(Canvas) and 3D (OpenGL) APIs can be used for more specialized GUIs Widget – “micro” unit of user interface (e.g. fields, buttons, labels, lists, etc.) Activity’s UI is made up of one or more widgets Activity with widgets Widgets, Containers, Resources, Fragments When activity has more than one widget, the app need to tell android how the widgets are organized Container classes – layout managers: Put widgets in rows, columns or more complex arrangements Layout resource file – describes how containers and widgets are connected. Resource refers to images, strings, or other materials not in form of programming language code. Widgets, Containers, Resources, Fragments UI Layout – another type of resource created using a structured tool or by hand in XML form Fragment – supporting large screens by “snapping together” parts of smaller screen (e.g. Gmail on a tablet shows list of labels, list of conversations in a selected label, and list of messages in a selected conversation, all in one activity, but Gmail on a phone cannot and shows labels, conversations, and messages in separate activities). Android Application Development Android Manifest Resource XML Java Source Generated Class Android Libraries Java Compiler .dex File Dalvik VM Apps and Packages javac Java code Byte code .java .class dx Dalvik exe classes.dex Byte code Other .class files aapt <xml> AndroidManifest.xml <str> Resources .apk Apps and Packages Application comes in the form of an APK file To distribute your apps, the APK file need to be uploaded to PlayStore A package must: be a valid Java package name, not exist for two applications on a device at the same time, not uploaded to PlayStore for two applications with same name Android Deployment • Apps are packaged in .apk format, variant of .jar, then downloaded to device and installed • .apk’s contain .dex files (bytecode), manifest and various other files • Manifest contains security and link info, hardware access info, minimum OS release info, etc. Emulator Shipped with android developer tools A program running on your development machine and behaves like an Android hardware Used to emulate many different devices with different devices, different screen sizes and Android OS versions, by creating one or more Android virtual devices, AVDs Android Application Dev Stages Write Java-syntax source code Compile the source code into Java VM bytecode using javac compiler Translates the Java VM bytecode into Dalvik VM bytecode, which is packaged with other files into the apk file Runs the apk file on android device or emulator, bytecode executed by an instance of a Dalvik VM Android Appl Development Process Starting Android Studio Configure Menu Installing Tools Installing tools Android SDK Tools, Platform-tools, and latest Build-tools SDK Platform for all Android SDK releases you want to code ARM EABI v7a System Image, Intel x86 Atom System Image, DO NOT choose Android 4.4 Documentation for Android SDK Installing tools Samples for SDK Android Support Library and Android Support Repository Choose Google USB Driver if you are running Windows “Hello, Android” Creating a New Project Set the min SDK setting to API 8 Creating an Activity Name the activity and title Project tool window (choose Android mode) Modify UI to display a larger text view object with different message • Locate activity_android_sample.xml under app -> res -> layout as below, and double click on it User Interface Designer tool Modifying the Apps • Delete the TextView component from the design: Click on the TextView object and press the Delete key on keyboard • In Pallete panel, locate the Widgets category. Click and drag the Large Text object and drop it in the center of the user interface design Change the text currently displayed Double click on the object