App Development for Android

Slides:



Advertisements
Similar presentations
Android Application Development A Tutorial Driven Course.
Advertisements

Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
What is Android?.
Android architecture overview
Android Platform Overview (1)
Android Aims to bring Internet-style innovation and openness to mobile phones.
App Development on Android
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
DEPARTMENT OF COMPUTER ENGINEERING
ANDROID OPERATING SYSTEM Guided By,Presented By, Ajay B.N Somashekar B.T Asst Professor MTech 2 nd Sem (CE)Dept of CS & E.
Android Google. Android An Open Handset Alliance Project Write apps to run on mobile phones Will be released as open source.
© 2010 MindTree Limited CONFIDENTIAL: For limited circulation only Slide 1 CONFIDENTIAL: For limited circulation only An automaton that is created from.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
1 CSCE 4013: Mobile Systems Programming Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
Android 101 Application Fundamentals January 29, 2010.
Mobile Application Development
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
App Development for Android Prabhaker Mateti. Development Tools (Android) Java – Java is the same. But, not all libs are included. – Unused: Swing, AWT,
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
To be Presented by, T.Sathishkumar [11mw07] 1. Synopsis Introduction Version Features License An Application Development Demo Possibilities Advantages.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Android Middleware Bo Pang
Android Introduction Platform Overview.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Mobile Application Development with ANDROID Tejas Lagvankar UMBC 29 April 2009.
Mobile Application Development with ANDROID. Agenda Mobile Application Development (MAD) Intro to Android platform Platform architecture Application building.
About me Yichuan Wang Android Basics Credit goes to Google and UMBC.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
01. Introduction to Android Prof. Oum Saokosal Master of Engineering in Information Systems, South Korea
ANDROID Presented By Mastan Vali.SK. © artesis 2008 | 2 1. Introduction 2. Platform 3. Software development 4. Advantages Main topics.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Android for Java Developers Denver Java Users Group Jan 11, Mike
ANDROID 응용 프로그래밍 과정 – 목차 - 안드로이드란 - 안드로이드가 만들어지게 된배경 - 안드로이드의 철학 - 안드로이드 환경설정 ( SDK download, eclipse plug-in 설정, 간단한 프로그램 실행 ) - 안드로이드 동작원리 - 안드로이드 핵심.
10/10/2015 E.R.Edwards 10/10/2015 Staffordshire University School of Computing Introduction to Android Overview of Android System Android Components Component.
Overview of Android Application Development
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
ANDROID BY:-AANCHAL MEHTA MNW-880-2K11. Introduction to Android Open software platform for mobile development A complete stack – OS, Middleware, Applications.
Created By. Jainik B Patel Prashant A Goswami Gujarat Vidyapith Computer Department Ahmedabad.
Android. Basic Architecture Linux Kernel Libraries Applications Android Runtime Application Framework.
1 Android Introduction Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
Mobile Application Development with ANDROID Umang Patel(6537) LDCE.
Lecture 2: Android Concepts
1 Android Workshop Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
Android operating system N. Sravani M. Tech(CSE) (09251D5804)
By Adam Reimel. Outline Introduction Platform Architecture Future Conclusion.
Android. Android An Open Handset Alliance Project A software platform and operating system for mobile devices Based on the Linux kernel Developed by Google.
Android Programming.
Android Mobile Application Development
Android Application -Architecture.
Android Introduction Hello World
Lecture 2: Android Concepts
Android 01: Fundamentals
Android Application Development 1 6 May 2018
Instructor: Mazhar Hussain
Architecture of Android
Android Runtime – Dalvik VM
Android Introduction Hello World.
CMPE419 Mobile Application Development
תכנות ב android אליהו חלסצ'י.
Application Development A Tutorial Driven Course
Emerging Platform#3 Android & Programming an App
Lecture 2: Android Concepts
CMPE419 Mobile Application Development
Presentation transcript:

App Development for Android Prabhaker Mateti

CEG 436 Specifics Because CEG 436 is a 10-week term course skipped for now refreshers on Operating Systems TCP/IP Networking Cellular Telephony “Definitions” Mobile Devices/Smart Phone What is Android? CEG436

Development Tools (Android) Java Eclipse ADT Plugin for Eclipse Java syntax is the same. But, not all libs are included. Unused: Swing, AWT, SWT, lcdui Eclipse www.eclipse.org/ ADT Plugin for Eclipse developer.android.com/sdk/eclipse-adt.html Android SDK developer.android.com/sdk/tools-notes.html Android Device Emulator Development Platforms: Linux, Mac OSX, or Windows CEG436

The Emulator QEMU-based ARM emulator Displays the same image as the device Limitations: No Camera support CEG436

Debugging adb acts as a middleman between a device and your development system. It provides various device management capabilities, including moving and syncing files to the emulator, running a UNIX shell on the device or emulator, and providing a general means to communicate with connected emulators and devices. Dalvik Debug Monitor Server DDMS is a graphical program that communicates with your devices through adb. DDMS can capture screenshots, gather thread and stack information, spoof incoming calls and SMS messages, and has many other features. Device or Android Virtual Device An adb device daemon runs on the device or emulator and provides a means for the adb host daemon to communicate with the device or emulator. JDWP debugger The Dalvik VM supports the JDWP protocol to allow debuggers to attach to a VM. Java IDEs include a JDWP debugger, or you can use a command line debugger such as jdb. CEG436

Android Application Package res/layout: declaration layout files res/drawable: intended for drawing res/anim: bitmaps, animations for transitions res/values: externalized values strings, colors, styles, etc res/xml: general XML files used at runtime res/raw: binary files (e.g., sound) An application consists of: Java Code Data Files Resources Files CEG436

Android Application Package Using Java/Eclipse/ADT develop several source code files. An Android application is bundled by the “aapt” tool into an Android package (.apk) An .apk file is a zip file. Invoke unzip if you wish. “Installing” an Application is a built-in op of Android OS. May need to enable the trustworthiness of developer CEG436

A Launcher: zeam-2.9.0.apk ( … a highly incomplete list … ) res/anim/apps_fade_in.xml res/color/bright_text_dark_focused.xml res/drawable/box_launcher_top.xml res/drawable/timepicker_up_selected.9.png res/layout/application_list.xml res/xml/preferences.xml AndroidManifest.xml resources.arsc res/drawable-hdpi/action_notifications.png res/layout-land/application.xml classes.dex META-INF/MANIFEST.MF META-INF/CERT.SF META-INF/CERT.RSA CEG436

Android Architecture

Android Architecture CEG436

Linux Kernel Works as a Hardware Abstraction Layer (HAL) Device drivers Keypad, Display, Power Mgmt, FlashMem, Binder, WiFi, Audio, Camera Memory management Process management Networking CEG436

Linux Kernel Enhancements Alarm Ashmem (Anonymous SHared MEMory) ashmem uses virtual memory, whereas pmem (process memory allocator) uses physically contiguous memory Binder an Android-specific inter-process communication mechanism, and remote method invocation system. Power Management Low Memory Killer echo "1536,2048,4096,15120,15360,23040" > /sys/module/lowmemorykiller/parameters/minfree Kernel Debugger Logger (system logging facility) CEG436

Android Runtime Dalvik VM Core Libraries a newly developed Java Virtual Machine dx tool translates .class files to .dex files Compact compared to .class files Optimized for memory and battery power Core Libraries Java Std Edition Collections, I/O etc… CEG436

Libraries Surface Manager: A compositing window manager similar to Compiz. Instead of drawing directly to the screen buffer, drawing commands go into off-screen bitmaps that are then combined with other bitmaps to form the display the user sees. Can create see-through windows, fancy transitions, … 2D and 3D graphics: Use 3D hardware or a software renderer. OpenGL. Media codecs: AAC, AVC (H.264), H.263, MP3, MPEG-4, … CEG436

Libraries SQLite database engine Browser engine: Provides persistent storage. Also used in Firefox and the iPhone. Browser engine: WebKit library for rendering web pages the same engine is used in KDE, the Google Chrome browser, Apple’s Safari browser, the iPhone, and Symbian 60. CEG436

Android NDK: Native C/C++ libraries not the full glibc as in Linux distros Supported CPUs: ARM, x86 libc (C library) headers libm (math library) headers JNI interface headers libz (Zlib compression) headers liblog (Android logging) header OpenGL ES headers libjnigraphics (Pixel buffer access) header A Minimal set of headers for C++ support OpenSL ES native audio libraries Android native application APIS Cross-toolchains (compilers, linkers, ...) CEG436

OpenGL ES OpenGL ES is a subset of OpenGL graphics standard. low-level interface for graphics acceleration. floating-point and fixed-point systems. OpenGL ES 1.X is for fixed function hardware and offers acceleration, image quality and performance. OpenGL ES 2.X enables full programmable 3D graphics. OpenGL SC is tuned for the safety critical market. http://www.khronos.org/opengles/ CEG436

Application Framework Views  lists, grids, text boxes, buttons, and even an embeddable web browser Content Providers to access data from other applications (such as Contacts), or to share their own data A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files A Notification Manager that enables all applications to display custom alerts in the status bar An Activity Manager that manages the lifecycle of applications and provides a common navigation backstack [sic] CEG436

Standard Applications Android provides a set of core applications: Email Client SMS Program Calendar Maps Browser Contacts Etc All applications are written using the Java language. CEG436

Android Application Internals

Application Fundamentals Each application is a different “user”. Each application gets a unique Linux user ID. The system sets permissions for all the files in an application so that only the user ID assigned to that application can access them. Each process has its own Dalvik VM. Every application runs in its own Linux process. A process can have multiple threads. CEG436

Application Components Activity  represents a single screen with a user interface. Service  runs in the background; Long-running; for remote processes no user interface. Content provider  manages a shared set of application data. Broadcast receiver  responds to broadcast announcements. An application can have multiple instances of the above four types. Each component is a different point through which the system can enter an application. Every component has a managed lifecycle. CEG436

.apk Internals AndroidManifest.xml — deployment descriptor for applications. IntentReceiver as advertised by the IntentFilter tag. *.java files implement Android activity Main.xml — visual elements, or resources, for use by activities. R.java —automatically generated by Android Developer Tools and "connects" the visual resources to the Java source code. Components share a Linux process: by default, one process per .apk file. .apk files are isolated and communicate with each other via Intents or AIDL. CEG436

Application Resources anything relating to the visual presentation of the application images, animations, menus, styles, colors, audio files, … resource ID alternate resources for different device configurations CEG436

AndroidManifest.xml Declares all application components: <activity> <service> <provider> for content providers <receiver> for broadcast receivers The manifest can also: Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts. Declare hardware and software features used or required by the application API libraries the application needs CEG436

Life cycle of an Android activity CEG436

Activity Typically, one of the activities is marked as the first one that should be presented to the user when the application is launched. Created “Activity” must be defined into the application’s manifest. An activity is usually a single screen: Implemented as a single class extending Activity. Displays user interface controls (views). Reacts on user input/events. CEG436

Activity An application typically consists of several screens: Each screen is implemented by one activity. Moving to the next screen means starting a new activity. An activity may return a result to the previous activity. CEG436

Service A service does not have a visual user interface, but rather runs in the background for an indefinite period time. Examples: music player, network download, etc Each service extends the Service base class. It is possible to bind to a running service and start the service if it's not already running. While connected, it is possible communicate with the service through an interface defined in AIDL (Android Interface Definition Language). CEG436

Services Similar to daemons in Linux/Unix or Windows services. Interprocess communication (IPC). A service is "started" when a component does a startService(). Stops with  stopSelf() or stopService() A service is "bound" when a component does a  bindService(). Multiple components can bind to the service at once. When all of them unbind, the service is destroyed. Can work both ways. (i) onStartCommand() allows components to start it and (ii) onBind() allows binding. (iii) onCreate() (iv) onDestroy() CEG436

Broadcast Receivers A broadcast receiver is a component that receives and reacts to broadcast announcements (Intents). All receivers extend the BroadcastReceiver base class. Many broadcasts originate in system code. the time zone has changed the battery is low Applications can also initiate broadcasts. CEG436

Content Providers Enables sharing of data across applications E.g. address book, photo gallery the only way to share data between applications. Provides uniform APIs for query, delete, update and insert. Applications do not call these methods directly. They use a ContentResolver object and call its methods instead. A ContentResolver can talk to any content provider. Content is represented by URI and MIME type. CEG436

Content Providers Activity Application Content Provider Service Data SQLite XML Remote Store Content Resolver CEG436

Intent Intents are system messages that notify applications of various events: Activity events ( launch app, press button) Hardware state changes (acceleration change, screen off, etc) Incoming data (Receiving call, SMS arrived) An intent object is an action to be performed on some data Uri. It provides runtime binding between the code in different applications. Examples: ACTION_DIAL content://contacts/people/13 Display the phone dialer with the person #13 filled in. ACTION_VIEW content://contacts/people/ Display a list of people, which the user can browse through. startActivity(new Intent(Intent.VIEW_ACTION, Uri.parse( "http://www.fhnw.ch")); startActivity(new Intent(Intent.VIEW_ACTION, Uri.parse("geo:47.480843,8.211293")); startActivity(new Intent(Intent.EDIT_ACTION, Uri.parse("content://contacts/people/1")); secondary attributes: category, type, component, extras  CEG436

public class Intent startActivity to launch an activity. broadcastIntent to send it to a BroadcastReceiver Communicate with a Service startService(Intent) or  bindService(Intent, ServiceConnection, int) Explicit Intents specify a component to be run. setComponent(ComponentName) or setClass(Context, Class)) Implicit Intents match an intent against all of the <intent-filter>s in the installed applications. Will return to this topic later. CEG436

Intent Filters A component can have any number of intent filters, each one declaring a different set of capabilities. The first filter in the example indicates that the activity is the entry point for the application. The second filter declares an action that the activity can perform on a particular type of data. CEG436

IntentReceivers Components that respond to broadcast ‘Intents’ Way to respond to external notification or alarms Apps can invent and broadcast their own Intent CEG436

Example App: Hello World! developer.android.com/resources/tutorials/hello-world.html

Goal Create a very simple application Run it on the emulator Examine its structure CEG436

Package Content All source code here Java code for our activity Generated Java code Helps link resources to Java code All non-code resources Layout of the activity Images Strings used in the program Android Manifest CEG436

Android Manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> CEG436

HelloAndroid.java Inherit from the Activity Class package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        TextView tv = new TextView(this);        tv.setText("Hello, Android – by hand");        setContentView(tv);    } } Set the view “by hand” – from the program CEG436

Run it! CEG436

HelloAndroid.java package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } Set the layout of the view as described in the main.xml layout CEG436

/res/layout/main.xml Further redirection to /res/values/strings.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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_height="wrap_content" android:text="@string/hello" /> </LinearLayout> Further redirection to /res/values/strings.xml CEG436

/res/values/strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloAndroid – by resources!</string> <string name="app_name">Hello, Android</string> </resources> CEG436

/gen/R.java package com.example.helloandroid; public final class R {     public static final class attr {     }     public static final class drawable {         public static final int icon=0x7f020000;     }     public static final class id {         public static final int textview=0x7f050000;     }     public static final class layout {         public static final int main=0x7f030000;     }     public static final class string {         public static final int app_name=0x7f040001;         public static final int hello=0x7f040000;     } } CEG436

Run it! CEG436

Introduce A Bug package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity {     /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         Object o = null;         o.toString();         setContentView(R.layout.main);     } } CEG436

Run it! CEG436

Case Studies of Applications

ADW.Launcher ADW.Launcher is an open source Home Replacement app. it is included as the main Launcher in Cyanogen's custom ROMs. I will be (??) using the source code of this app as a running example. Download the source from http://code.google.com/p/adw-launcher-android/ CEG436

Project Suggestions Augmented Campus Reality Games camera + maps + compass = heads up info Games multi-player (bluetooth, wifi, cell) location-based (scavenger hunt) Custom overlays for maps weather, traffic, friends Web scraping news filters sport scores dook news eliminators more on next slide … Distributed computing? 10,000 phones all donating their idle time tiny terminal (phone) + fast cpu/network (server) Shared whiteboard CEG436

Project Suggestions Web Scrapers [movies, weather, sports, <topic> news] Find multiple web sources Scrape them for the relevant information Present in a custom UI on the phone Asynchronous games [chess, poker, risk] Develop an API for all games to communicate through Establish connections by phone number Send and receive game data Ability to reopen connections  Planner/To-do list with location data Decide route to next class, meeting, etc Find a order/route for non time-critical tasks Connect to campus directory to find teachers/classmates CEG436

Source Code for Android Examples Sources for many Android applications that can be enhanced: http://code.google.com http://developer.android.com/resources/browser.html?tag=sample CEG436