CS 403X Mobile and Ubiquitous Computing Lecture 3: Introduction to Android Programming Emmanuel Agu

Similar documents
CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 1b: Introduction to Android. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

Fig. 2.2 New Android Application dialog. 2.3 Creating an App 41

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

XML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.

Produced by. Mobile Application Development. Eamonn de Leastar David Drohan

CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu

CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing. Lab & Demo 2 (1 &2 of 3) Hello-Goodbye App Tutorial

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

Android HelloWorld - Example. Tushar B. Kute,

Introduction To Android

CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing. Lab & Demo 2 (Part 1-2) Hello-Goodbye App Tutorial

Chapter 2 Welcome App

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

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

This document providesanoverview ofthestepsrequired to implement an android app which will call the ACH android SDK.

COMP4521 EMBEDDED SYSTEMS SOFTWARE

How to support multiple screens using android? Synopsis

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Playing Sound and Video Emmanuel Agu

Mobile Application Development - Android

Getting Started with Android Development Zebra Android Link-OS SDK Android Studio

EMBEDDED SYSTEMS PROGRAMMING UI and Android

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

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

Programming Concepts and Skills. Creating an Android Project

ANDROID SYLLABUS. Advanced Android

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu

BCA 6. Question Bank

Required Core Java for Android application development

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

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

Styles, Themes, and Material Design

CS 403X Mobile and Ubiquitous Computing Lecture 5: Web Services, Broadcast Receivers, Tracking Location, SQLite Databases Emmanuel Agu

Building MyFirstApp Android Application Step by Step. Sang Shin Learn with Passion!

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

Quick Reference Guide

Android Application Development

Introduction to Android

CMSC 436 Lab 10. App Widgets and Supporting Different Devices

Programming with Android: Application Resources. Dipartimento di Scienze dell Informazione Università di Bologna

Android Programming Lecture 2 9/7/2011

Style, Themes, and Introduction to Material Design

CS378 -Mobile Computing. More UI -Part 2

Programming with Android: Application Resources. Dipartimento di Scienze dell Informazione Università di Bologna

Step 1 Download and Install KompoZer Step by step instructions to build your first web page using KompoZer web editor.

ECOM 5341 Mobile Computing(Android) Eng.Ruba A. Salamah

Page Layout Using Tables

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

Programming Android UI. J. Serrat Software Design December 2017

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

CS 403X Mobile and Ubiquitous Computing Lecture 14: Google Places, Other Useful Android APIs and Cool Location Aware Apps Emmanuel Agu

INTRODUCTION TO ANDROID

Mobile Programming Lecture 1. Getting Started

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

Android Development Tutorial. Yi Huang

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

Resources and Media and Dealies

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

Learn Dreamweaver CS5 in a Day

Table of contents. 2 Samsung Care. 3 Know Your Device. 5 S Pen. 7 Device Setup. 12 Home Screen. 18 Apps. 19 Calls. 20 Voic .

Mobile App Design Project Doodle App. Description:

(Refer Slide Time: 0:48)

Android Beginners Workshop

In this Class Mark shows you how to put applications into packages and how to run them through the command line.

The drawable/tile empty.xml file

USER GUIDE. MADCAP FLARE 2018 r2. Images

Chapter 5 Defining the Manifest

ECE 1778: Creative Applications for Mobile Devices

Android Essentials with Java

Android App Development

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Sony Smart headset products Developer specifications

Android. Lesson 1. Introduction. Android Developer Fundamentals. Android Developer Fundamentals. to Android 1

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Create a Contact Sheet of Your Images Design a Picture Package Customize Your Picture Package Layout Resample Your Image...

Strengths of Knox Manage Kiosk

Configuring the Android Manifest File

Android Application Development. By : Shibaji Debnath

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

Introductory Android Development

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

Creating Forms. Starting the Page. another way of applying a template to a page.

Mobile OS. Symbian. BlackBerry. ios. Window mobile. Android

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

Lesson 3 Images and WordArt Basics

Content Elements. Contents. Row

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

Programming Mobile Applications with Android Lab1

Table of Contents 2 Device Functions 4 Device Setup 8 Call Features 9 Voic Customize Your Device 12 Contacts 13 Messages 15 Connections

Apple News Apple Advertising Platforms Specifications November 2017

Transcription:

CS 403X Mobile and Ubiquitous Computing Lecture 3: Introduction to Android Programming Emmanuel Agu

Android UI Tour

Home Screen First screen, includes favorites tray (e.g phone, mail, messaging, web, etc)

All Apps Screen Accessed by touching all apps button in favorites tray Can swipe through multiple app screens, customizable Android 5.0 all apps button Android 5.0

Recent Apps Screen Accessed by touching recent apps button Shows recently used apps, touch app to switch to it recent apps button Android 5.0

Status Bar and Notification Screen Status: time, battery, cell signal strength, bluetooth enabled, etc Notification: wifi, mail, bewell, voicemail, usb active, music, etc Status bar Notification Screen

Android Apps: Big Picture

UI Design using XML UI design code (XML) separate from the program (Java) Why? Can modify UI without changing Java program Example: Shapes, colors can be changed in XML file without changing Java program UI designed using either: Drag and drop graphical (WYSIWYG) tool or Programming Extensible Markup Language (XML) XML: Markup language, both humanreadable and machine readable''

Android App Compilation Android Studio compiles code, data and resource files into Android PacKage (filename.apk)..apk is similar to.exe on Windows Apps download from Google Play, or copied to device as filename.apk Installation = installing apk file

Activities Activity? 1 Android screen or dialog box Apps Have at least 1 activity that deals with UI Entry point, similar to main( ) in C Typically have multiple activities Example: A camera app Activity 1: to focus, take photo, launch activity 2 Activity 2: to view photo, save it Activities independent of each other E.g. Activity 1 can write data, read by activity 2 App Activities derived from Android s Activity class

Our First Android App

3 Files in Hello World Android Project Activity_my.xml: XML file specifying screen layout MainActivity.Java: Java code to define behavior, actions taken when button clicked (intelligence) AndroidManifest.xml: Lists all screens, components of app Analogous to a table of contents for a book E.g. Hello world program has 1 screen, so AndroidManifest.xml has 1 item listed App starts running here (like main( ) in C) Note: Android Studio creates these 3 files for you

Execution Order Next: Samples of AndroidManifest.xml Hello World program Start in AndroidManifest.xml Read list of activities (screens) Start execution from Activity tagged Launcher Create/execute activities (declared in java files) E.g. MainActivity.Java Format each activity using layout In XML file (e.g. Activity_my.xml)

Inside Hello World AndroidManifest.xml This file is written using xml namespace and tags and rules for android Your package name Android version List of activities (screens) in your app One activity (screen) designated LAUNCHER. The app starts running here

Execution Order Start in AndroidManifest.xml Read list of activities (screens) Start execution from Activity tagged Launcher Next Create/execute activities (declared in java files) E.g. MainActivity.Java Format each activity using layout In XML file (e.g. Activity_my.xml)

Example Activity Java file (E.g. MainActivity.java) Package declaration Import needed classes My class inherits from Android activity class Initialize by calling oncreate( ) method of base Activity class Note: Android calls your Activity s oncreate method once it is created Use screen layout (design) declared in file main.xml

Execution Order Start in AndroidManifest.xml Read list of activities (screens) Start execution from Activity tagged Launcher Create/execute activities (declared in java files) E.g. MainActivity.Java Next Format each activity using layout In XML file (e.g. Activity_my.xml)

Simple XML file Designing UI After choosing the layout, then widgets added to design UI XML Layout files consist of: UI components (boxes) called Views Different types of views. E.g TextView: contains text, ImageView: picture, WebView: web page Views arranged into layouts or ViewGroups Declare Layout Add widgets Widget properties (e.g. center contents horizontally and vertically)

Android Files

Android Project File Structure

Android Project File Structure Java code for app. E.g. What happens on user input, etc XML files for look or layout of Android screens

Android Project File Structure 3 Main Files to Write Android app

Files in an Android Project res/ folder contains static resources you can embed in Android screen (e.g. pictures, string declarations, etc) res/menu/: XML files for menu specs res/drawable xyz/: images (PNG, JPEG, etc) at various resolutions res/raw: general purpose files (e.g. audio clips, CSV files res/values/: strings, dimensions, etc

Concrete Example: Files in an Android Project res/layout: layout, dimensions (width, height) of screen cells are specified in XML file here res/drawable xyz/: The images stored in jpg or other format here java/: App s behavior when user clicks on a selection in java file here AndroidManifext.XML: Contains app name (Pinterest), list of app screens, etc

Basic Overview of an App Tutorial 8: Basic Overview of an App [11:36 mins] https://www.youtube.com/watch?v=9l1lfwaihpg Main topics Introduces main files of Android App Activity_main.xml MainActivity.java AndroidManifest.xml How to work with these files within Android Studio Editting files using either drag and drop interface or XML Flow of basic app

Editting Android Activity_my.xml (can edit directly) Activity_my.xml is XML file specifying screen layout, widgets Can edit XML directly or drag and drop App running on Emulator (can edit Text, drag and drop)

Activity_main.xml Widgets: elements that can be dragged onto activity (screen) Design View: Design app screen using Drag and drop widgets Design view

Activity_main.xml: Text View Text view: Design screen by editting XML file directly Note: dragging and dropping widgets auto generates corresponding XML

MainActivity.java Java code, defines actions, handles interaction/put taken (intelligence) E.g. What app will do when button/screen clicked

AndroidManifest.xml App s starting point (a bit like main( ) in C)

Resources

Declaring Strings in Strings.xml Can declare all strings in strings.xml String declaration in strings.xml Then reference in any of your app s xml files

Strings in AndroidManifest.xml Strings declared in strings.xml can be referenced by all other XML files (activity_my.xml, AndroidManifest.xml) String declaration in strings.xml String usage in AndroidManifest.xml

Where is strings.xml in Android Studio? Editting any string in strings.xml changes it wherever it is displayed

Styled Text In HTML, tags can be used for italics, bold, etc E.g. <i> Hello </i> makes text Hello <b> Hello <b> makes text Hello Can use the same HTML tags to add style (italics, bold, etc) to Android strings

Phone Dimensions Used in Android UI Physical dimensions measured diagonally E.g. Nexus 4 is 4.7 inches diagonally Resolution in pixels E.g. Nexus 4 resolution 768 x 1280 pixels Pixels per inch (PPI) = Sqrt[(768 x 768) + (1280 x 1280) ] / 4.7= 318 Dots per inch (DPI) is number of pixels in a physical area Low density (ldpi) = 120 dpi Medium density (mdpi) = 160 dpi High density (hdpi) = 240 dpi Extra High Density (xhdpi) = 320 dpi

Adding Pictures Android supports images in PNG, JPEG and GIF formats Default directory for images (drawables) is res/drawable xyz Images in res/drawable xyz can be referenced by XML and java files res/drawable ldpi: low dpi images (~ 120 dpi of dots per inch) res/drawable mdpi: medium dpi images (~ 160 dpi) res/drawable hdpi: high dpi images (~ 240 dpi) res/drawable xhdpi: extra high dpi images (~ 320 dpi) res/drawable xxhdpi: extra extra high dpi images (~ 480 dpi) res/drawable xxxhdpi: high dpi images (~ 640 dpi) Images in these directories are different resolutions, same size

Adding Pictures Just the generic picture name is used (no format e.g. png) No specification of what resolution to use E.g. to reference an image ic_launcher.png Android chooses which directory (e.g. mdpi) at run time based on actual device resolution Android studio tools for generating icons Icon wizard or Android asset studio: generates icons in various densities from starter image Cannot edit images (e.g. dimensions) with these tools

Styles Styles specify rules for look of Android screen Similar to Cascaded Style Sheets (CSS) in HTML E.g CSS enables setting look of certain types of tags. E.g. font and size of all <h1> and <h2> elements Android widgets have properties E.g. Foreground color = red Styles in Android: collection of values for properties Styles can be specified one by one or themes (e.g. Theme, Theme.holo and Theme.material) can be used

Default Themes Android chooses a default theme if you specify none Many stock themes to choose from Theme.Holo: default theme in Android 3.0 Theme.Material: default theme in Android 5.0

Examples of Themes in Use GMAIL in Holo Light Settings screen in Holo Dark

References Busy Coder s guide to Android version 4.4 CS 65/165 slides, Dartmouth College, Spring 2014 CS 371M slides, U of Texas Austin, Spring 2014 Android App Development for Beginners videos by Bucky Roberts (thenewboston)