Developing an Android App. CSC207 Fall 2014



Similar documents
By sending messages into a queue, we can time these messages to exit the cue and call specific functions.

Presenting Android Development in the CS Curriculum

ANDROID APP DEVELOPMENT: AN INTRODUCTION CSCI /19/14 HANNAH MILLER

Android Application Development. Yevheniy Dzezhyts

Building Your First App

Android App Development. Rameel Sethi

MMI 2: Mobile Human- Computer Interaction Android

Tutorial #1. Android Application Development Advanced Hello World App

Developing Android Apps: Part 1

Mobile Application Development

Now that we have the Android SDK, Eclipse and Phones all ready to go we can jump into actual Android development.

ADITION Android Ad SDK Integration Guide for App Developers

Chapter 2 Getting Started

Android Development. Marc Mc Loughlin

Getting Started: Creating a Simple App

@ME (About) Marcelo Cyreno. Skype: marcelocyreno Linkedin: marcelocyreno Mail:

MAP524/DPS924 MOBILE APP DEVELOPMENT (ANDROID) MIDTERM TEST OCTOBER 2013 STUDENT NAME STUDENT NUMBER

Android Development Tutorial. Human-Computer Interaction II (COMP 4020) Winter 2013

Android For Java Developers. Marko Gargenta Marakana

Android Quiz App Tutorial

Create Your Own Android App Tools Using ArcGIS Runtime SDK for Android

Android Introduction. Hello Mihail L. Sichitiu 1

ELET4133: Embedded Systems. Topic 15 Sensors

How to Create an Android Application using Eclipse on Windows 7

Tutorial: Setup for Android Development

Getting Started With Android

Android Basics. Xin Yang

Arduino & Android. A How to on interfacing these two devices. Bryant Tram

Introduction to Android SDK Jordi Linares

Developing Android Applications: Case Study of Course Design

Android Programming Basics

Hello World. by Elliot Khazon

HERE SDK for Android. Developer's Guide. Hybrid Plus Version 2.1

HERE SDK for Android. Developer's Guide. Online Version 2.1

Android Concepts and Programming TUTORIAL 1

Android Bootcamp. Elaborado (com adaptações) a partir dos tutoriais:

2. Installieren des MySQL Workbench (Version ) 3. Unter Database > Manage Connection folgende Werte eintragen

Android Development Tutorial

Saindo da zona de conforto resolvi aprender Android! by Daniel Baccin

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

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

A software stack for mobile devices:

Introduction to Android: Hello, Android! 26 Mar 2010 CMPT166 Dr. Sean Ho Trinity Western University

Admin. Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources. Recap: TinyOS. Recap: J2ME Framework

directory to "d:\myproject\android". Hereafter, I shall denote the android installed directory as

How to develop your own app

ANDROID TUTORIAL. Simply Easy Learning by tutorialspoint.com. tutorialspoint.com

ANDROID AS A PLATFORM FOR DATABASE APPLICATION DEVELOPMENT

Basics. Bruce Crawford Global Solutions Manager

Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作

Android Programming. Android App. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Android Java Live and In Action

Android Application Development Lecture Notes INDEX

INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011

Lab 1 (Reading Sensors & The Android API) Week 3

Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 2 Android Platform. Marco Picone

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

Automatically Scaling Android Apps For Multiple Screens

Android Application Development: Hands- On. Dr. Jogesh K. Muppala

Getting started with Android and App Engine

Android App Development Lloyd Hasson 2015 CONTENTS. Web-Based Method: Codenvy. Sponsored by. Android App. Development

How to build your first Android Application in Windows

Woubshet Behutiye ANDROID ECG APPLICATION DEVELOPMENT

Smartphone market share

2. Click the download button for your operating system (Windows, Mac, or Linux).

Wireless Communication Using Bluetooth and Android

Android Development. 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系

4. The Android System

Report and Opinion 2014;6(7) Technical Specification for Creating Apps in Android. Kauser Hameed, Manal Elobaid

Based on Android 4.0. by Lars Vogel. Version 9.8. Copyright 2009, 2010, 2011, 2012 Lars Vogel Home Tutorials Trainings Books Social

Jordan Jozwiak November 13, 2011

IOIO for Android Beginners Guide Introduction

Developing Android Applications Introduction to Software Engineering Fall Updated 7 October 2015

Introduction to Android

23442 ECE Introduction to Android Mobile Programming ECE Special Topics: Android Mobile Programming

Advertiser Campaign SDK Your How-to Guide

Introduction to Android

Developing NFC Applications on the Android Platform. The Definitive Resource

AdFalcon Android SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

Android Environment SDK

Android Persistency: Files

OpenCV on Android Platforms

ANDROID ALERT APP (SHOP SALE)

Android Programming and Security

Creating a List UI with Android. Michele Schimd

Location-Based Services Design and Implementation Using Android Platforms

Android-based Java Programming for Mobile Phone LED Control

Transcription:

Developing an Android App CSC207 Fall 2014

Overview Android is a mobile operating system first released in 2008. Currently developed by Google and the Open Handset Alliance. The OHA is a consortium of 84 firms that develop standards for mobile devices. It includes Dell, Intel, NVidia, Samsung, Sony, and others. Members of the consortium are not permitted to run nonstandard versions of Android. Over a billion active devices use Android.

Android OS Versions Image source: Wikipedia We will use Android 4.3 (Jellybean) on CDF (demo today is on 4.4)

Android Software Development For your project, you ll develop a software application for the Android operating system. You ll implement your app using Java and the Android Software Development Kit (SDK). The SDK includes tools such as a debugger and an emulator, plus libraries and documentation. Eclipse is (still) the officially supported IDE. (Android Studio is still in beta.) On CDF: eclipse-android

Emulator We ll run our apps using a mobile device emulator. It is a virtual mobile device that runs on our computers, so no mobile device is required for software development. It has the software and hardware features of a real device, but you can t actually make calls!

Demo We ll write an application based on our running example. A Registry application that collects information about the population and stores the data in a file. The remaining slides summarize the demo.

These are the settings you must use for your project. New Android Project

The main Activity An app is made up of multiple Activity s. In this example, an Activity corresponds to a single screen with a user interface. The first Activity is typically called the main activity.

WYSIWYG view of main Activity This is a TextView.

XML View of main Activity This displays the text Hello world! @string/hello_world is set to Hello world! in file strings.xml

strings.xml The string used by the TextView.

Changing the text displayed by TextView We ll add a new string to string.xml: <string name="header">register a person</string> We ll change the variable used by the TextView in activity_main.xml: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/header" />

Changing the layout Two types of layouts are: - LinearLayout: components are arranged horizontally or vertically. - RelativeLayout: components are arranged relative to something else (e.g., at the left edge of a component). We ll edit activity_main.xml to use a LinearLayout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".mainactivity" >... </LinearLayout>

In activity_main.xml, below the TextView: Adding two EditText fields <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <EditText android:id="@+id/first_name_field" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="@string/first_name" /> <EditText android:id="@+id/last_name_field" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="@string/last_name" /> </LinearLayout> hints These are EditTexts. In strings.xml: <string name="first_name">first name</string> <string name="last_name">last name</string>

Adding a Button In activity_main.xml, below the 2nd EditText: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/submit_text" android:onclick="registerperson" /> In strings.xml, add a new string: <string name="submit_text">submit</string> But nothing happens when we click the button! We need to implement method registerperson.

MainActivity.java This code was auto-generated when the project was created.

Implementing registerperson When the button is clicked, we specified that the method registerperson will be called: // Note: an onclick method must return void and have one View parameter. public void registerperson(view view) { // Specifies the next Activity to move to: DisplayActivity. Intent intent = new Intent(this, DisplayActivity.class); // Gets the first name from the 1st EditText field. EditText firstnametext = (EditText) findviewbyid(r.id.first_name_field); String firstname = firstnametext.gettext().tostring(); // Gets the last name from the 2nd EditText field. EditText lastnametext = (EditText) findviewbyid(r.id.last_name_field); String lastname = lastnametext.gettext().tostring(); String[] name = {firstname, lastname}; Person person = new Person(name, 11, 21, 2010); // To do: add EditTexts for dob. // Passes the Person object to DisplayActivity. intent.putextra("personkey", person); } startactivity(intent); // Starts DisplayActivity.

File -> New -> Class Adding our Person class Add our Person class to the package. We ll modify the Person class so that it implements Serializable and has a UID: public class Person implements Serializable {... } // This UID was generated by Eclipse. private static final long serialversionuid = -9021932579037461512L; To pass complex objects from one Activity to another, the data must be serialized. Serializing data translates it into a storable form that can be converted back to original form.

Adding Another Activity File -> New -> Other -> Android -> Android Activity This generates activity_display.xml and DisplayActivity.java.

Edit DisplayActivity.java The oncreate method is called when the Activity is created. Get the Person object passed from MainActivity and display the name of the Person: @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_display); // Gets the Intent passed from MainActivity Intent intent = getintent(); Part of activity_display.xml: <TextView android:id="@+id/newly_registered" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/newly_registered"/> // Uses key "PersonKey" to get Person object. Person person = (Person) intent.getserializableextra("personkey"); String[] names = person.getname(); } // Sets TextView to the Person's name. TextView newlyregistered = (TextView) findviewbyid(r.id.newly_registered); newlyregistered.settext(names[1] + ", " + names[0] + " has been registered.");

Transition between activities MainActivity DisplayActivity Complex objects pass via the Intent from one Activity to another must be serialized. Multiple objects can be passed by giving each a different key.

Running