Android Application Development 1 6 May 2018

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.
Android OS : Core Concepts Dr. Jeyakesavan Veerasamy Sr. Lecturer University of Texas at Dallas
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
Android Overview. Android (Google) is a widely anticipated open source operating system for mobile devices, Supporting Bluetooth ( wireless for short.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
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.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
@2011 Mihail L. Sichitiu1 Android Introduction Application Fundamentals.
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
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.
Android Application Development 2013 PClassic Chris Murphy 1.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
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.
© 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.
Operating system for mobile devices with a Java programming interface. Provides tools, e.g. a compiler, debugger, device emulator, and its own Java Virtual.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Intro to Android Development Ben Lafreniere. Getting up and running Don’t use the VM! ials/hello-world.html.
DUE Hello World on the Android Platform.
CS378 - Mobile Computing Intents.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
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
Eclipse Tutorial Barrett Summer Scholars 2011 Sustainable Engineering: Learning to Engineer Truly Green Products.
Presented By: Muhammad Tariq Software Engineer Android Training course.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
Overview of Android Application Development
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
First Venture into the Android World Chapter 1 Part 2.
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.
 Installation of Android Development Environment  Creating the App with OpenGL ES API  Running the App on Emulator Android App Development.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
Introduction to Android Programming
Android Programming.
Lab7 – Appendix.
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Lecture 2: Android Concepts
Android 01: Fundamentals
Android N Amanquah.
Android Introduction Hello World.
Android.
MAD.
Development-Introduction
Broadcast Receivers A Android Component where you can register for system or application events, receive and react to broadcast intent. Each broadcast.
תכנות ב android אליהו חלסצ'י.
Mobile Device Development
Application Fundamentals
Application Development A Tutorial Driven Course
CMPE419 Mobile Application Development
Emerging Platform#3 Android & Programming an App
Introduction to Android
Application Fundamentals
Android Overview.
CMPE419 Mobile Application Development
Android Development Introduction to Android Development 2011/01/16
Chapter 5 Your Second Activity.
Presentation transcript:

Android Application Development 1 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 1

What is Android? An open source Linux-based operating system intended for mobile computing platforms Includes a Java API for developing applications It is not a device or product 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 2

6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 3

What Skills Will Students Learn? Reinforce the basics: OOP, decomposition, etc. Separation of UI design and functionality XML and resource files Events and Listeners Callback methods Threads 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 4

Android vs. iPhone Java vs. Objective-C Direct install vs. Marketplace vs. App Store Open source? 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 5

What Should Students Already Know? Java! inheritance, method overriding interfaces, casting exceptions debugging reading API documentation Eclipse easy to pick up quickly, though 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 6

Do I Need Phones? The emulator that is part of the Android toolset for Eclipse is quite good (though a bit slow) You may be able to get free “developer phones” from Google 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 7

Online Resources developer.android.com code.google.com/p/apps-for-android/ stackoverflow.com videos from Google I/O conferences 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 8

Concepts: activity, service, broadcast receiver, content provider, Understand applications and their components Concepts: activity, service, broadcast receiver, content provider, intent, AndroidManifest 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Applications Written in Java (it’s possible to write native code – will not cover that here) Good separation (and corresponding security) from other applications: Each application runs in its own process Each process has its own separate VM Each application is assigned a unique Linux user ID – by default files of that application are only visible to that application (can be explicitly exported) 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Application Components Activities – visual user interface focused on a single thing a user can do Services – no visual interface – they run in the background Broadcast Receivers – receive and react to broadcast announcements Content Providers – allow data exchange between applications 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Activities Basic component of most applications Most applications have several activities that start each other as needed Each is implemented as a subclass of the base Activity class 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Activities – The View Each activity has a default window to draw in (although it may prompt for dialogs or notifications) The content of the window is a view or a group of views (derived from View or ViewGroup) Example of views: buttons, text fields, scroll bars, menu items, check boxes, etc. View(Group) made visible via Activity.setContentView() method. 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Services Does not have a visual interface Runs in the background indefinitely Examples Network Downloads Playing Music TCP/UDP Server You can bind to a an existing service and control its operation 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Broadcast Receivers Receive and react to broadcast announcements Extend the class BroadcastReceiver Examples of broadcasts: Low battery, power connected, shutdown, timezone changed, etc. Other applications can initiate broadcasts 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Content Providers Makes some of the application data available to other applications It’s the only way to transfer data between applications in Android (no shared files, shared memory, pipes, etc.) Extends the class ContentProvider; Other applications use a ContentResolver object to access the data provided via a ContentProvider 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Intents An intent is an Intent object with a message content. Activities, services and broadcast receivers are started by intents. ContentProviders are started by ContentResolvers: An activity is started by Context.startActivity(Intent intent) or Activity.startActivityForResult(Intent intent, int RequestCode) A service is started by Context.startService(Intent service) An application can initiate a broadcast by using an Intent in any of Context.sendBroadcast(Intent intent), Context.sendOrderedBroadcast(), and Context.sendStickyBroadcast() 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Shutting down components Activities Can terminate itself via finish(); Can terminate other activities it started via finishActivity(); Services Can terminate via stopSelf(); or Context.stopService(); Content Providers Are only active when responding to ContentResolvers Broadcast Receivers Are only active when responding to broadcasts 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Android Manifest Its main purpose in life is to declare the components to the system: <?xml version="1.0" encoding="utf-8"?> <manifest . . . >     <application . . . >         <activity android:name="com.example.project.FreneticActivity"                   android:icon="@drawable/small_pic.png"                   android:label="@string/freneticLabel"                   . . .  >         </activity>         . . .     </application> </manifest> 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

Intent Filters Declare Intents handled by the current application (in the AndroidManifest): <?xml version="1.0" encoding="utf-8"?> <manifest . . . >     <application . . . >         <activity android:name="com.example.project.FreneticActivity"                   android:icon="@drawable/small_pic.png"                   android:label="@string/freneticLabel"                   . . .  >             <intent-filter . . . >                 <action android:name="android.intent.action.MAIN" />                 <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>             <intent-filter . . . >                 <action android:name="com.example.project.BOUNCE" />                 <data android:mimeType="image/jpeg" />                 <category android:name="android.intent.category.DEFAULT" />             </intent-filter>         </activity>         . . .     </application> </manifest> Shows in the Launcher and is the main activity to start Handles JPEG images in some way 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID

“Hello, Android” 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 21

Creating Your First(?) Android App Set up your development environment Create a new Android project in Eclipse Run it in the emulator Hilarity ensues 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 22

1. Set Up Your Android Environment http://developer.android.com/sdk Install Eclipse Install Android SDK (Android libraries) Install ADT plugin (Android development tools) Create AVD (Android virtual device) We’ve already done this for you!! 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 23

2. Create an Android Project in Eclipse File → New → Project Select “Android Project” Fill in Project details... 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 24

Directory name Android version Java package Name that appears on device Class to automatically create 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 25

3. Run the Android Application Run → Run (or click the “Run” button) Select “Android Application” The emulator may take a few minutes to start, so be patient! You don't need to restart the emulator when you have a new version of your application 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 26

6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 27

Source code Auto-generated code String constants UI layout Configuration 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 28

HelloAndroid.java 1 public class HelloAndroid extends Activity { 2  /** Called when the activity is first created. */ 3    @Override 4    public void onCreate(Bundle savedInstanceState) 5 { 6      super.onCreate(savedInstanceState); 7        setContentView(R.layout.main); 8    } 9 } 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 29

main.xml 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:orientation="vertical" 5 android:layout_width="fill_parent" 6 android:layout_height="fill_parent" 7 > 8 <TextView 9 android:layout_width="fill_parent" 10 android:layout_height="wrap_content" 11 android:text="@string/hello " 12 /> 13 </LinearLayout> 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 30

strings.xml 1 <?xml version="1.0" encoding="utf-8"?> 2 <resources> 3 <string name="hello">Hello World, HelloAndroid! 4 </string> 5 <string name="app_name">Hello, Android</string> 6 </resources> 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 31

AndroidManifest.xml 1 <?xml version="1.0" encoding="utf-8"?> 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 package="edu.upenn.cis542" 5 android:versionCode="1" 6 android:versionName="1.0"> 7 <application android:icon="@drawable/icon" 8 android:label="@string/app_name"> 9 <activity android:name=".HelloAndroid" 10 android:label="@string/app_name"> 11 <intent-filter> 12 <action 13 android:name="android.intent.action.MAIN" /> 14 <category 15 android:name="android.intent.category.LAUNCHER"/> 16 </intent-filter> 17 </activity> 18 </application> 19 </manifest> 6 May 2018 S.RENUKADEVI/AP/SCD/INTRODUCTION TO ANDROID 32