Top Banner
Android Application Development Stephen Diniz [email protected] Computer/Electrical Engineer Lecture 01 Introduction
29

Android Application Development Stephen Diniz [email protected] Computer/Electrical Engineer Lecture 01 Introduction.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

AndroidApplicationDevelopment

Stephen [email protected]/Electrical Engineer

Lecture 01

Introduction

Page 2: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Setting Up Your IDE An IDE is an Integrated Development

Environment and is made to aid developers in creating and debugging projects.

IDE’s typically include syntax highlighting, a debugger, auto-completion, and a solution builder.

Page 3: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Java’s JDK Like any programming language,

development kits are required in order for your computer to compile and interpret your code.

Since Android is heavily based off Java, most concepts can be directly implemented during your development.

http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

Page 4: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Eclipse Eclipse is a very powerful IDE and is

recommended by Google to use when developing for Android.

http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigor

Page 5: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Step 1: Install the Java JDK Go to the provided link on slide 3 and

download the version of the JDK that best fits your operating system.

For Windows Vista/7 users running the 64-bit operating system, make sure to download the Windows x64 version of the Java Development Kit.

Page 6: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Step 2: Downloading Eclipse Eclipse, like the Java JDK, comes in

Linux/Window/Mac builds (32-bit/64-bit).

Choose the one that best fits you and unzip it.

The most convenient place to have Eclipse is in your root directory:

C:\Eclipse -Windows/home/user/eclipse/ -Linux

Page 7: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Step 3: Installing the ADT The ADT, or Android Development

Tools, is a plugin for Eclipse designed to give powerful integration to your environment.

The most recent version of the ADT (as of 9/21/11) is ADT 12.0.0

The ADT installation instructions can be found here:

http://developer.android.com/sdk/eclipse-adt.html

Page 8: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

The Java Programming Language Primitive Data Types: (notice lowercase)

byte short int long float double boolean char

Page 9: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

The Java Programming Language Objects

String BigDecimal

Require methods in order to do most things, such as finding out if two strings are equal.

Incorrect Correct

Page 10: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Java “Hello world!” Program

http://www.thenewboston.com/?cat=36&pOpen=tutorial

Java Tutorials:

Page 11: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Android “Hello world” Application Programmatically:

Page 12: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Android “Hello world” Application Utilizing XML:

Page 13: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Android “Hello world” Application Utilizing XML (continued):

Page 14: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

The Result is identical

Page 15: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Which Approach To Use? Mostly preference, however… For larger, more complex applications, I

would highly recommend the XML approach

XML makes it easy to modify properties of Objects on the screen (Buttons, TextViews, etc) For larger, more complex applications, I would highly recommend the XML approach

Page 16: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Do I have to choose? No, for the most part, XML and the code

play nicely together. Accessing an object in an XML file

requires one line of code and its attributes can be read and modified.

Page 17: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

For Example Let’s return to the second Hello world

example and modify the TextView’s content.

The XML file will go unchanged, but note the TextView’s android:id

Page 18: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Binding to the TextView The following code will bind to the Hello

world’s TextView and change its contents to “Android is Awesome!”

android:id

Page 19: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.
Page 20: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

The Android Developer Reference Website This website contains all the information

about Android methods and objects in order to do things programmatically.

Most methods (that refer to XML objects) can be altered via XML and Java relatively easily.

http://developer.android.com/reference/android/provider/package-summary.html

Page 21: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Using the Reference Website Let’s look up how to create a text field,

or in Android, an EditText

We’re going to search EditText in the search field and choose the android.widget.EditText option.

Page 22: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Using the Reference Website If you scroll down a bit you’ll find a

section called Public Methods.

Page 23: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

Using the Reference Website Let’s make a simple App that will get

the content of an EditText, mirror the String, and set the EditText’s content to the new, mirrored String.

Any ideas?

Page 24: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

String Mirroring App

Note: getText() returns an Editable object.

If we click the Editable link and read up quickly, we’ll notice Editable “implements” GetChars, Spannable, Appendable, and most importantly (for this project), CharSequence

Page 25: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

String Mirroring App Let’s scroll down to the Inherited Methods and see

what methods are available “From interface android.text.CharSequence

In this case, the method of interest is toString() because of its return type String.

Page 26: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

String Mirroring App Perfect, we have two functions,

getText() and setText() to do that main operations we want to our EditText object.

The rest of the mirroring is purely Java and can be done in a few different ways.

Page 27: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

String Mirroring App

Page 28: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.

String Mirroring App

Page 29: Android Application Development Stephen Diniz sdiniz@umassd.edu Computer/Electrical Engineer Lecture 01 Introduction.