1 Programming in Android. 2 Outline 3 What you get from Android An Android Application is a Loosely-Coupled Software System The Project Structure The.

Slides:



Advertisements
Similar presentations
Google Android Introduction to Mobile Computing. Android is part of the build a better phone process Open Handset Alliance produces Android Comprises.
Advertisements

Ando-it-yourself droid Praveen Kumar Pendyala. Outline Brief intro to the Droid developement Setting up the Life saviors - Development tools Hello Droid.
Application Fundamentals Android Development. Announcements Posting in D2L Tutorials.
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
Android 101 Application Fundamentals January 29, 2010.
Android: Hello World Frank Xu Gannon University. Steps Configuration ▫Android SDK ▫Android Development Tools (ADT)  Eclipse plug-in ▫Android SDK and.
Android and Project Structure. Android Android OS – Built on Linux Kernel – Phones – Netbooks – Readers – Other???
Mobile Application Development
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 PROGRAMMING MODULE 1 – GETTING STARTED
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Emerging Platform#4: Android Bina Ramamurthy.  Android is an Operating system.  Android is an emerging platform for mobile devices.  Initially developed.
Using Ant to build J2EE Applications Kumar
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
Presented by…. Group 2 1. Programming language 2Introduction.
Chapter 1: Voilà! Meet the Android. Smartphones –Can browse the Web –Allow you to play games –Use business applications –Check –Play music –Record.
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.
Introducing the Sudoku Example
Chapter 3 Navigating a Project Goals & Objectives 1.Get familiar with the navigation of the project. How is everything structured? What settings can you.
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.
Android Programming By Mohsen Biglari Android Programming, Part1: Introduction 1 Part1: Introduction By Mohsen Biglari.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
Rajab Davudov. Agenda Eclipse, ADT and Android SDK APK file Fundamentals – Activity – Service – Content Provider – Broadcast Receiver – Intent Hello World.
Mobile Application Development using Android Lecture 2.
DUE Hello World on the Android Platform.
CS378 - Mobile Computing Intents.
Android for Java Developers Denver Java Users Group Jan 11, Mike
Chapter 12: Finale! Publishing Your Android App
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
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
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
Configuring Android Development Environment Nilesh Singh.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Creating an Example Android App in Android Studio Activity lifecycle & UI Resources.
ANDROID L. Grewe Components  Java Standard Development Kit (JDK) (download) (latest version)  AndroidStudio.
 Installation of Android Development Environment  Creating the App with OpenGL ES API  Running the App on Emulator Android App Development.
ANDROID APPLICATION DEVELOPMENT. ANDROID DEVELOPMENT DEVELOPER.ANDROID.COM/INDEX.HTML THE OFFICIAL SITE FOR ANDROID DEVELOPERS. PROVIDES THE ANDROID SDK.
Intoduction to Andriod studio Environment With a hello world program.
Resources & Android Manifest Калин Кадиев Astea Solutions AD.
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. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
CHAPTER 1 part 1 Introduction. Chapter objectives: Understand Android Learn the differences between Java and Android Java Examine the Android project.
Introduction to Android Programming
Mobile Applications (Android Programming)
Android Mobile Application Development
Android 01: Fundamentals
Mobile Application Development BSCS-7 Lecture # 2
Obtaining the Required Tools
MAD.
Anatomy of an Android Application
CS5103 Software Engineering
Android Application Development
Android Platform, Android App Basic Components
Emerging Platform#3 Android & Programming an App
Mobile Programming Dr. Mohsin Ali Memon.
Introduction to Android
Presentation transcript:

1 Programming in Android

2

Outline 3 What you get from Android An Android Application is a Loosely-Coupled Software System The Project Structure The Manifest File

What you get from Android 4 You get a commonly-used programming language (Java) some commonly used libraries (e.g., some Apache Commons APIs), support for tools you may be used to (Eclipse)

What you get from Android 5 You get a fairly rigid framework in which your programs need to run and do not interfere with other programs or the operation of the phone itself

What you get from Android 6 Storage databases or files Network Android devices will generally be Internet-ready Raw Java sockets available Built-in WebKit-based Web browser (as Safari) widget you can embed in your application

What you get from Android 7 Multimedia play back and record audio and video. GPS Android devices will frequently have access to location providers Phone Services initiate calls by programs send and receive SMS messages

An Android Application is a Loosely- Coupled Software System 8 Activities Content Providers Intents Intent Receivers/Broadcast Receiver Services

Activities 9 The building block of the user interface. The Android analogue for the window or dialog in a desktop application.

Content Providers 10 Content providers provide a level of abstraction for any data stored on the device that is accessible by multiple applications. The Android development model encourages you to make your own data available to other applications.

Intents 11 Intents are system messages, running around the inside of the device, notifying applications of various events, hardware state changes (e.g., an SD card was inserted), incoming data (e.g., an SMS message arrived), application events (e.g., your activity was launched from the device's main menu).

Intents 12 You can receive and respond to intents by intent filters intent/broadcast receivers You can create your own intents to launch other activities, let you know when specific situations arise (e.g., raise an intent when the user gets within 100 meters of a specified location)

Services 13 Activities, content providers, and intent receivers are all short-lived and can be shut down at any time. Services are long-lived and can be independent of activities.

Services 14 You might use a service for checking for updates to an RSS feed playing back music even if the controlling activity is no longer operating.

Overview of a Project 15 The Android build system is organized around a specific directory tree structure for your Android project, much like any other Java project.

Items in the project's root directory: 16 AndroidManifest.xml: an XML file describing the application being built and what components – activities, services, etc. – are being supplied by that application build.xml: an Ant script for compiling the application and installing it on the device default.properties: a property file used by the Ant build script

Items in the project's root directory: 17 bin/: holds the application once it is compiled libs/: holds any third-party Java JARs your application requires src/: holds the Java source code for the application

Items in the project's root directory: 18 res/: holds "resources", such as icons, GUI layouts, and the like, that get packaged with the compiled Java in the application assets/: hold other static files you wish packaged with the application for deployment onto the device

When you create a project 19 When you created the project, you supplied the fully- qualified class name of the "main" activity for the application (e.g., edu.nsysu.android.SomeDemo). You will then find that your project's src/ tree already has the namespace directory tree in place, plus a stub Activity subclass representing your main activity (e.g., src/edu/nsysu/android/SomeDemo.java).

When you compile a project 20 The first time you compile the project (e.g., via ant), out in the "main“ activity's namespace directory, the Android build chain will create R.java. This contains a number of constants tied to the various resources you placed out in the res/ directory tree. You should not modify R.java yourself, letting the Android tools handle it for you. You will see throughout many of the samples where we reference things in R.java (e.g., referring to a layout's identifier via R.layout.main).

The “res” directory 21 This directory holds "resources" – static files that are packaged along with your application Some of the subdirectories you will find or create under res/ include: res/drawable/ for images (PNG, JPEG, etc.) res/layout/ for XML-based UI layout specifications res/menu/ for XML-based menu specifications res/raw/ for general-purpose files (e.g,. a CSV file of account information) res/values/ for strings, dimensions, and the like res/xml/ for other general-purpose XML files you wish to ship

The “bin” directory 22 When you compile your project (via ant or the IDE), the results go into the bin/ directory under your project root: bin/classes/ holds the compiled Java classes bin/classes.dex holds the executable created from those compiled Java classes bin/yourapp.ap_ holds your application's resources, packaged as a ZIP file (where yourapp is the name of your application) bin/yourapp-debug.apk or bin/yourapp-unsigned.apk is the actual Android application (where yourapp is the name of your application)

The “bin” directory 23 The.apk file is a ZIP archive containing the.dex file, the compiled edition of your resources (resources.arsc), any un-compiled resources (such as what you put in res/raw/) and the AndroidManifest.xml file. It is also digitally signed, with the -debug portion of the filename indicating it has been signed using a debug key that works with the emulator, or -unsigned indicating that you built your application for release (ant release), but the APK still needs to be signed using jarsigner and an official key.

24 <manifest xmlns:android=" package=“edu.nsysu.android"> <uses-permission android:name="android.permission.ACCESS_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" /> <uses-permission android:name="android.permission.ACCESS_CELL_ID" />.../* activities, intent filters, broadcast receivers, services and etc */

On The Manifest File 25 The root of all manifest files is a manifest element. The biggest piece of information you need to supply on the manifest element is the package attribute. Here, you can provide the name of the Java package that will be considered the “base“ of your application. Then, everywhere else in the manifest file that needs a class name, you can just substitute a leading dot as shorthand for the package.

On The Manifest File 26 For example, if you needed to refer to edu.nsysu.android.search.Snicklefritz in this manifest shown above, you could just use “.Search.Snicklefritz”, since com.commonsware.android is defined as the application's package.

More Elements 27 uses-permission elements (requires your own application): to indicate what permissions your application will need in order to function properly permission elements (requires other applications): to declare permissions that activities or services might require other applications hold in order to use your application's data or logic

More Elements 28 instrumentation elements: to indicate code that should be invoked on key system events, such as starting up activities, for the purposes of logging or monitoring uses-library elements: to hook in optional Android components, possibly a uses-sdk element: to indicate what version of the Android SDK the application was built for an application element

The Children of The Application Element 29 The real meat of the manifest file are the children of the application element. By default, when you create a new Android project, you get a single activity element. This element supplies android:name for the class implementing the activity, android:label for the display name of the activity, an intent-filter child element describing under what conditions this activity will be displayed.

The Children of The Application Element 30 The stock activity element sets up your activity to appear in the launcher, so users can choose to run it. You can have several activities in one project and each activity corresponds to a “phone screen”.

31 <manifest xmlns:android=" package=“edu.nsysu.android.skeleton">

Intent Receivers 32 You may also have one or more receiver elements, indicating non-activities that should be triggered under certain conditions, such as when an SMS message comes in. These are called intent receivers.

Content Providers 33 You may have one or more content providers – components that supply data to your activities and, with your permission, other activities in other applications on the device. These wrap up databases or other data stores into a single API that any application can use.

Services 34 You may also have one or more services – long-running pieces of code that can operate independent of any activity. The quintessential example is the MP3 player, where you want the music to keep playing even if the user pops open other activities and the MP3 player's user interface is hidden.

Reference 35 Reto Meier, Professional Android Application Development, 2009, Wrox, USA. Mark L. Murphy, The Busy Coder's Guide to Android Development, 2009, CommonsWare, LLC., USA.