App Development for Android Prabhaker Mateti. Development Tools (Android) Java – Java is the same. But, not all libs are included. – Unused: Swing, AWT,

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.
Android architecture overview
App Development for Android
Android Aims to bring Internet-style innovation and openness to mobile phones.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android 101 Application Fundamentals January 29, 2010.
Mobile Application Development
Google Android as a mobile development platform T Internet Technologies for Mobile Computing Olli Mäkinen.
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.
Android GUI Project John Hurley CS 454. Android 1. Android Basics 2. Android Development 3. Android UI 4. Hello, World 5. My Project.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
© Frank Mueller & Seokyong Hong (TA) North Carolina State University Center for Efficient, Secure and Reliable Computing Android Installation Guide (2)
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
1 Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources, Listener 10/9/2012 Y. Richard Yang.
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
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.
Introducing the Sudoku Example
CS5103 Software Engineering Lecture 08 Android Development II.
© 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.
Introduction to Android Programming (CS5248 Fall 2015) Aditya Kulkarni August 26, 2015 *Based on slides from Paresh Mayami.
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.
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
DUE Hello World on the Android Platform.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
CE Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running.
Android for Java Developers Denver Java Users Group Jan 11, Mike
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.
Configuring Android Development Environment Nilesh Singh.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
1 Android Introduction Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
Lecture 2: Android Concepts
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
Introduction to Android Programming
Android Programming.
Android Application -Architecture.
Android Introduction Hello World
Lecture 2: Android Concepts
Android 01: Fundamentals
Android Application Development 1 6 May 2018
Android N Amanquah.
Lecture 2 Zablon Ochomo Android Programming Lecture 2 Zablon Ochomo
Instructor: Mazhar Hussain
Android Introduction Hello World.
CMPE419 Mobile Application Development
תכנות ב android אליהו חלסצ'י.
Android GUI Project John Hurley CS 454.
Application Development A Tutorial Driven Course
Android GUI Project John Hurley CS 454.
Emerging Platform#3 Android & Programming an App
Lecture 2: Android Concepts
CMPE419 Mobile Application Development
Presentation transcript:

App Development for Android Prabhaker Mateti

Development Tools (Android) Java – Java is the same. But, not all libs are included. – Unused: Swing, AWT, SWT, lcdui Eclipse ADT Plugin for Eclipse developer.android.com/developer.android.com/ Android SDK developer.android.com/developer.android.com/ Android Device Emulator Development Platforms: Linux, Mac OSX, or Windows 2Mateti/Android

(Other) Languages and IDEs IntelliJ Idea Android Studio Corona for Android Android Native Development Kit (NDK) Scala 3Mateti/Android

Application Runtime 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/Art VM. Every application runs in its own Linux process. A process can have multiple threads. 4Mateti/Android

Application Framework Views lists, grids, text boxes, buttons, embeddable web browser Views Content Providers to access data from other applications, or to share their own data Content Providers Resource Manager access non-code resources; e.g., strings, graphics, and layout files Resource Manager Notification Manager alerts in the status bar Notification Manager Activity Manager lifecycle of applications and navigation backstack Activity Manager 5Mateti/Android

Application Components Activity: (GUI) functions that the application performs. Service: no UI – run in the background; Long-running; for remote processes – no user interface. Content Providers facilitate data transmission among different applications. Broadcast Receiver: respond to announcements. Groups of views define the application’s layout. Each component is a different entry point of the system. An application can have multiple instances of the above. 6Mateti/Android

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. 7Mateti/Android

Activity One of the activities is marked as the main one. Presented on launch. An activity is usually a single screen: – Implemented as a single class extending Activity. – Displays user interface controls (views). – Reacts on user input/events. 8Mateti/Android

Life cycle of an Activity 9Mateti/Android

Services A service does not have a (visual) user interface. Runs in the background for an indefinite period time. – Examples: music player, network download, … Similar to daemons in Linux/Unix or Windows services. Each service extends the Service base class. Communicate with the service through an interface defined in AIDL (Android Interface Definition Language). 10Mateti/Android

Services Interprocess communication (IPC). startService(); stopSelf() ; stopService() startService()stopSelf()stopService() bindService(). Multiple components can bind to the service at once. When all of them unbind, the service is destroyed. bindService() onStartCommand() onBind() onCreate() onDestroy() 11Mateti/Android

Broadcast Receivers Broadcast announcements: Intents. All receivers extend the BroadcastReceiver base class. Many broadcasts originate in the System. – Ex: the time zone has changed – Ex: the battery is low Applications can also initiate broadcasts. 12Mateti/Android

Content Providers Enables sharing of content across applications – E.g., address book, photo gallery – the only way to share data between applications. APIs for query, delete, update and insert. Use ContentResolver methods to do the above. Content is represented by URI and MIME type. 13Mateti/Android

Content Providers 14Mateti/Android

Intent Examples ACTION_DIAL content://contacts/people/13 ACTION_DIAL – Display the phone dialer with the person #13 filled in. ACTION_VIEW content://contacts/people/ ACTION_VIEW – Display a list of people, which the user can browse through. startActivity(new Intent(Intent.VIEW_ACTION, Uri.parse( " startActivity(new Intent(Intent.VIEW_ACTION, Uri.parse("geo: , ")); startActivity(new Intent(Intent.EDIT_ACTION, Uri.parse("content://contacts/people/1")); attributes: category, type, component, extras 15Mateti/Android

Intent Intents are system messages: – 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. Provides binding between applications.URI 16Mateti/Android

public class Intent startActivity to launch an activity. startActivity broadcastIntent to send it to a BroadcastReceiver broadcastIntent Communicate with a Service – startService(Intent) or startService(Intent) – bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int) Explicit Intents specify a component to be run. – setComponent(ComponentName) or setComponent(ComponentName) – setClass(Context, Class)) setClass(Context, Class) Implicit Intents match an intent against all of the s in the installed applications. 17Mateti/Android

IntentReceivers Components that respond to Intents Way to respond to external notification or alarms Apps can create and broadcast own Intents 18Mateti/Android

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

The Emulator QEMU-based ARM emulator Displays the same image as the device Limitations: –Camera –GPS 20Mateti/Android

21 Goal Create a very simple application Run it on the emulator Examine its structure Mateti/Android

Building HelloAndroid Create a Project – app/creating-project.html app/creating-project.html Generates several files – Next few slides Modify HelloAndroid.java as needed 22Android-Develop-1

23 helloandroid Manifest 1. 2.<manifest xmlns:android=" 3. package="com.example.helloandroid" 4. android:versionCode="1" 5. android:versionName="1.0"> <activity android:name=".HelloAndroid" Mateti/Android

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. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } 24 Set the layout of the view as described in the main.xml layout Mateti/Android

25 HelloAndroid.java 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. 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 Inherit from the Activity Class Mateti/Android

26 Run it! Mateti/Android

Android Application Package: APK 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 27Mateti/Android

28 APK Content Java code for our activityAll source code here Generated Java code Helps link resources to Java code Layout of the activity Strings used in the program All non-code resources Android Manifest Images Mateti/Android

Android Application Package: APK Using Java/Eclipse/ADT develop source 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. 29Mateti/Android

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

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 31Mateti/Android

AndroidManifest.xml Declares all application components: – – – for content providers – 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 32Mateti/Android

33 /res/layout/main.xml <LinearLayout xmlns: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" /> Further redirection to /res/values/strings.xml Mateti/Android

34 /res/values/strings.xml Hello World, HelloAndroid – by resources! Hello, Android Mateti/Android

/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; } } R.java is auto generated on build. Based on the resource files (including layouts and preferences) Do not edit. Mateti/Android35

36 Run it! Mateti/Android

Debugging adb Android Debug Bridge adb – moving and syncing files to the emulator – running a Linux shell on the device or emulator Dalvik Debug Monitor Server – DDMS is GUI + adb. – capture screenshots – gather thread and stack information – spoof incoming calls and SMS messages Device or Android Virtual Device DeviceAndroid Virtual Device JDWP Java Debug Wire Protocol – Java IDEs include a JDWP debugger – command line debuggers such as jdb.jdb 37Mateti/Android

38 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. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Object o = null; o.toString(); setContentView(R.layout.main); } } Mateti/Android

39 Run it! Mateti/Android

Source Code for Android Examples Sources for many Android applications that can be enhanced: ser.html?tag=sample ser.html?tag=sample 40Mateti/Android