Lecture 2 Android SDK

Similar documents
Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Android System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015

Lecture 1 - Introduction to Android

Mobile Application Development Android

Mobile Application Development Android

Android Fundamentals - Part 1

ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS

Minds-on: Android. Session 2

Mobile Computing. Introduction to Android

Application Fundamentals

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Mobile Application Development Android

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

Android App Development. Muhammad Sharjeel COMSATS Institute of Information Technology, Lahore

application components

CS378 -Mobile Computing. Services and Broadcast Receivers

Android App Development. Ahmad Tayeb

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle

Understanding Application

CS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

Services are software components designed specifically to perform long background operations.

Android Application Development

Programming in Android. Nick Bopp

Android Overview. Most of the material in this section comes from

Introduction to Android

Content Provider. Introduction 01/03/2016. Session objectives. Content providers. Android programming course. Introduction. Built-in Content Provider

Android Basics. Android UI Architecture. Android UI 1

Mobile Application Development - Android

Android Ecosystem and. Revised v4presenter. What s New

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

Activities and Fragments

Lecture 08. Android Permissions Demystified. Adrienne Porter Felt, Erika Chin, Steve Hanna, Dawn Song, David Wagner. Operating Systems Practical

Praktikum Mobile und Verteilte Systeme. Android-Basics. Prof. Dr. Claudia Linnhoff-Popien André Ebert, Sebastian Feld

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Android Essentials with Java

Introduction. Lecture 1. Operating Systems Practical. 5 October 2016

Android framework. How to use it and extend it

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

Android Online Training

CS371m - Mobile Computing. Content Providers And Content Resolvers

ANDROID DEVELOPMENT. Course Details

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING UI and Android

Security model. Marco Ronchetti Università degli Studi di Trento

CE881: Mobile & Social Application Programming

Getting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento

Android Application Development 101. Jason Chen Google I/O 2008

Android-Basics. Praktikum Mobile und Verteilte Systeme. Prof. Dr. Claudia Linnhoff-Popien André Ebert, Sebastian Feld

Introduction to Android Android Smartphone Programming. Outline University of Freiburg. What is Android? Background University of Freiburg.

COSC 3P97 Mobile Computing

Android-Basics. Praktikum Mobile und Verteilte Systeme

ATC Android Application Development

Syllabus- Java + Android. Java Fundamentals

ANDROID APPS (NOW WITH JELLY BEANS!) Jordan Jozwiak November 11, 2012

Android Programming - Jelly Bean

Required Core Java for Android application development

Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Mobile Application Development Android

Security Philosophy. Humans have difficulty understanding risk

Java Training Center - Android Application Development

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

COLLEGE OF ENGINEERING, NASHIK-4

Why using intents. Activity. Screen1 Screen 2

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers

MARS AREA SCHOOL DISTRICT Curriculum TECHNOLOGY EDUCATION

CS378 -Mobile Computing. Intents

Software Practice 3 Today s lecture Today s Task

android application development CONTENTS 1.1 INTRODUCTION TO O ANDROID OPERATING SYSTEM... TURES Understanding the Android Software Stack...

Answers to Exercises

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

PAPER ON ANDROID ESWAR COLLEGE OF ENGINEERING SUBMITTED BY:

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

Contextual Android Education

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

INTRODUCTION TO ANDROID

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

MC Android Programming

IGEEKS TECHNOLOGIES. Software Training Division. Academic Live Projects For BE,ME,MCA,BCA and PHD Students

CHAPTER 1: HELLO, ANDROID 1

Android Camera. Alexander Nelson October 6, University of Arkansas - Department of Computer Science and Computer Engineering

Another difference is that the kernel includes only the suspend to memory mechanism, and not the suspend to hard disk, which is used on PCs.

Data storage and exchange in Android

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Real-Time Embedded Systems

Mobile development initiation

Android Application Development using Kotlin

ITG Software Engineering

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

CMSC436: Fall 2013 Week 4 Lab

Lifecycle-Aware Components Live Data ViewModel Room Library

App Development for Android. Prabhaker Matet

Lecture 3 Android Internals

Android System Development Day-4. Team Emertxe

Spring Lecture 5 Lecturer: Omid Jafarinezhad

Android Development Tutorial. Yi Huang

Transcription:

Lecture 2 Android SDK This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

Android Manifest xml file In the root of the app directory Describes application components and resources Application name and Java package (unique) Activities, Services, Broadcast Receivers, Content Providers Start activity Permissions Libraries Minimum API level 2

Permissions Determine what resources and APIs an application can access Meant to provide security through sandboxing Declared in the Manifest <uses-permission android:name="android.permission.receive_sms" /> Permission is asked at install time: all or nothing Can not be granted afterwards Control who can access your components and resources Start activity, start or bind service, send broadcasts, access data in Content Provider URI permissions 3

Resources res/ directory Each resource type in a different subdirectory with specific name drawable/, layout/, values/, menu/, xml/, etc. The default resources For different configurations we may need different resources Bigger screen -> different layout Different language -> different strings Subdirectory for each alternative set of resources <resources_name>-<config_qualifier> drawable-hdpi/ for High Density Screens Resource chosen at runtime based on the configuration An ID is generated for each resource name in gen/ 4

Layouts Resources from res/layouts/ Describe the UI of an activity or part of the UI res/layout/filename.xml Filename is used as resource ID UI elements Can be edited as an xml or using the tools provided Easy to learn, hard to master 5

Drawables Resources from res/drawables/ Element that can be drawn on the screen Can be images (.png,.jpg, or.gif) or xmls xmls describe how an UI element reacts to input (pressed, focused) xmls point to images Visual feedback for interaction 6

Activity Application component User interface window, provide user interaction Require a layout Can only draw and change UI from the Looper thread Computationally intensive or wait based tasks on separate threads An application may include multiple activities Only one is the main activity Activities can start each other -> the previous one is stopped Activity stack ("back stack") Back -> activity destroyed and previous one resumed 7

Activity Lifecycle Source: http://developer.android.com 8

Activity Lifecycle Activities can be killed after onpause(), onstop() in low memory situations The activity state (objects) are lost Can preserve state by saving objects User interaction can be saved and restored Callback onsaveinstancestate() Save information in a Bundle oncreate(), onrestoreinstancestate() Restore the activity state Threads can be stopped graciously In onpause() threads should be signaled to stop 9

Save Activity State Source: http://developer.android.com 10

UI UI is a hierarchy of views View: rectangular space, provides user interaction Buttons, Lists, Fragments, Images, Text Boxes Callbacks for actions A ViewGroup includes other View or ViewGroup objects Classes can be extended to provide more complex views Adapters allow for more complex data types to be displayed 11

Service Performs operations in the background Does not provide a UI Continues to run even if another application is in foreground Is able to perform network transactions, le I/O operations, interact with content providers, etc. Runs in the main thread of the hosting process A separate thread should be created if the service performs CPU intensive or blocking operations 12

Service Can be started by any application using an Intent Block access from other apps by declaring the service as private in the manifest It may run as an independent application, with no UI, that provides functionality to other applications Is started when another application binds to it Or using am start service 13

Types of Services Started An application component calls startservice() Performs a single operation, then stops itself and does not return a result to the caller Runs even if the caller component is destroyed Bound An application component binds to it by calling bindservice() Provides a client-server interface - send requests, return results Runs as long as the application component is bound to it Multiple components can bind to a service at once Service destroyed after all components unbind 14

Service Lifecycle Source: http://developer.android.com 15

Intent An object used for delivering a message Used for Starting an activity Starting or binding a service Delivering a broadcast message Includes component name, action and data Intent filters Declare the types of intents that a component can receive Specified in the manifest - <intent-filter> <action>, <data> 16

Types of Intents Explicit intents Specify exactly which component to start (the class name) Typically used to start components in your own app Will be delivered even if there is no intent filter declared Implicit intents Do not specify the exact component Declare a general action to be performed The Android system finds the appropriate component Compares the intent to the intent filters in the manifest of the apps 17

Implicit Intents Source: http://developer.android.com 18

Broadcast Receiver Responds to system-wide broadcast announcements The system generates many broadcasts Example: battery is low, screen has turned o, etc. Apps can generate broadcasts - send an announcement for other apps No UI, may create a notification in the status bar to alert the user The receiver lets other components perform the work based on the event 19

Broadcast Receiver Each broadcast is delivered as an Intent Intent passed to startbroadcast() startorderedbroadcast() Local broadcasts using LocalBroadcastManager More efficient Data does not leave the app Other apps cannot send the broadcast - no security holes Register a receiver in two ways Statically in the manifest using the <receiver> tag Dynamically using Context.registerReceiver() or 20

Types of Broadcasts Normal broadcasts Completely Asynchronous All receivers run in an undefined order Ordered broadcasts Delivered to one receiver at a time Each receiver executes and may propagate the result to the next or abort the broadcast The order is determined using the android:priority in the <intent-filter> of the receiver 21

Content Provider Provide access to a repository of data To access a provider you have to request specific permissions (in the manifest) <uses-permission android:name="android.permission.read_user_ DICTIONARY"> Two ways of storing data File data - audio, video, photos Structured data - database, array, etc. Form compatible with tables of rows and columns Usually a SQLite database 22

Content Provider Interface for accessing data in one process from another process Provider and provider client The application that owns the data includes the provider The client application owns the provider client Access data using a ContentResolver client object Its methods provide CRUD (create, retrieve, update, delete) functions Calls the methods with the same name in the ContentProvider object 23

Content URIs Identify data in the provider Include a symbolic name for the provider (authority) and a name for the table (path) Example: content://user_dictionary/words The ContentResolver uses the authority for identifying the provider From a system table with all known providers The ContentResolver sends a query to the provider The ContentProvider uses the path to identify the table 24

Bibliography http://developer.android.com/guide/topics/manifest/ma nifest-intro.html http://developer.android.com/guide/topics/resources/ov erview.html http://developer.android.com/guide/components/activiti es.html http://developer.android.com/guide/components/service s.html http://developer.android.com/guide/topics/providers/co ntent-providers.html http://developer.android.com/guide/components/intents -filters.html 25

Keywords Manifest file Permissions Resources Layouts Drawables Activity Service Intent Broadcast Receiver Content Provider Content URI 26