cs260 intro to java & android...

12
CS260 Intro to Java & Android 03.Intro Fall 2011 Fall 2011 CS250 - Intro to Java & Android 1

Upload: others

Post on 11-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

CS260 Intro to Java & Android 03.Intro

Fall 2011

Fall 2011 CS250 - Intro to Java & Android 1

Page 2: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Android - Getting Started

Android SDK contains:

API Libraries

Developer Tools

Documentation

Sample Code

Best development environment is Eclipse with the Android Developer Tool (ADT) plugin which integrates developer tools

Fall 2011 CS250 - Intro to Java & Android 2

Page 3: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Android Portability

Android applications run within the Dalvik virtual machine

Development Platforms:

Windows (XP, Windows, 7)

Linux

Mac OS 10.4.8 or later (Intel chips only)

Fall 2011 CS250 - Intro to Java & Android 3

Page 4: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Android HelloWorld Application

File -> New -> Project then select Android Project

Fall 2011 CS250 - Intro to Java & Android 4

Page 5: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

New Android Project

Fall 2011 CS250 - Intro to Java & Android 5

Page 6: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

HelloWorld Project Choices

Project name: HelloWorld

Build Target: Select Android 1.5

Every Android device can upgrade to Android 1.5

Application name: HelloWorld

Package name: edu.pacificu.cs.HelloWorld

Create Activity: HelloWorldActivity

Min SDK Version: 3

Fall 2011 CS250 - Intro to Java & Android 6

Page 7: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Skip “New Android Test Project”

Fall 2011 CS250 - Intro to Java & Android 7

Page 8: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

HelloWorld Android Project

Fall 2011 CS250 - Intro to Java & Android 8

Page 9: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Running Your Android Application

Before you can run an Android application, you need to create a new Android Virtual Device (AVD)

Window->Android SDK and AVD Manager

Create a virtual device called AVD1.5 using the 1.5 Platform

Use an SD Card of 32MB for later

Fall 2011 CS250 - Intro to Java & Android 9

Page 10: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Virtual Devices

Fall 2011 CS250 - Intro to Java & Android 10

Page 11: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

Run HelloWorld on AVD1.5

Fall 2011 CS250 - Intro to Java & Android 11

Page 12: CS260 Intro to Java & Android 03zeus.cs.pacificu.edu/ryand/cs260/2011/Lectures/03.AndroidIntro.pdf · Android Portability Android applications run within the Dalvik virtual machine

A Quick Look At HelloWorld

//HelloWorld.java package edu.pacificu.cs.HelloWorld; import android.app.Activity; import android.os.Bundle; public class HelloWorld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.main); } }

Fall 2011 CS250 - Intro to Java & Android 12