Intro to Android Development
description
Transcript of Intro to Android Development
![Page 1: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/1.jpg)
Intro to Android Development
Ben Lafreniere
![Page 2: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/2.jpg)
Getting up and running• Don’t use the VM!• http://developer.android.com/resources/tutor
ials/hello-world.html• Steps:– Install Eclipse– Install the Android Development Tools (ADT)
plugin– Install the Android SDK (may be optional)– Create an emulator– Hello world!
![Page 3: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/3.jpg)
Download and Install Eclipse• Eclipse has many versions!• Go with Eclipse Classic
(32- or 64-bit depending on your system)• http://www.eclipse.org/downloads
![Page 4: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/4.jpg)
Install ADT plugin
• http://developer.android.com/sdk/eclipse-adt.html#installing
![Page 5: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/5.jpg)
Download and Install the Android SDK
• http://developer.android.com/sdk/index.html
![Page 6: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/6.jpg)
Use SDK Manager to install APIs
• Why so many SDK versions?– Android is a UI toolkit being incrementally
developed before our eyes
• Install and use Android 2.3.3 SDK (API 10)– Because these are the phones we’ll be marking on
![Page 7: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/7.jpg)
Video walkthrough
• anddev_installing.avi
![Page 8: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/8.jpg)
Creating an emulator
• Not all developers have android devices– So we emulate one!
• Video– anddev_create_emu.avi
![Page 9: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/9.jpg)
Developing with the Emulator
• Emulator takes a long time to boot up– Enabling the ‘Snapshot’ option speeds things up
by saving the emulator’s state when it’s closed, and restoring it when it’s started again
• You can keep the emulator open between runs
• Don’t develop on the VM!(the emulator will run way too slow)
![Page 10: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/10.jpg)
Android Programming
![Page 11: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/11.jpg)
Creating an Android project• http://developer.android.com/resources/tutorials/hello-
world.html
![Page 12: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/12.jpg)
Hello World!
• HelloAndroidActivity.java
![Page 13: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/13.jpg)
Android App Anatomy – Classes
• Activity – A single screen of the application
• View – The superclass for widgets(the UI is made up of a tree of View objects)
• Intent – An action that must be performed
![Page 14: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/14.jpg)
Activities
• A single, focused thing that the user can do• Should use an Activity for each screen of the
application• Activities must be declared in the Manifest file
![Page 15: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/15.jpg)
Views
• Superclass of all Android widgets(similar to java.awt.Component in Swing)
![Page 16: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/16.jpg)
Views
• Superclass of all Android widgets(similar to the Component class from Swing)
![Page 17: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/17.jpg)
Intents• Abstract description of an action that the user
wants to perform (e.g. open a webpage,share a picture)
• Used to transition betweenActivities
• Includes the intended action,and may include data
![Page 18: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/18.jpg)
Code Examples• HelloAndroid – One Activity, One TextView,
very simple
• FormExample – Two Activities, using an Intent to start a second Activity
• DataPassExample – Builds on FormExample, using Intents to pass data between Activities
![Page 19: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/19.jpg)
Much more
• Using XML layouts to separate presentation from logic
• Using strings.xml in lieu of hard-coded strings
• Saving the application’s state when an activity is paused
![Page 20: Intro to Android Development](https://reader035.fdocuments.net/reader035/viewer/2022070421/56815fff550346895dcefce1/html5/thumbnails/20.jpg)
Useful references• Android Developers
http://developer.android.com• Tutorials section
http://developer.android.com/resources/browser.html?tag=tutorial
• Notebook tutorial (detailed multi-Activity example)http://developer.android.com/resources/tutorials/notepad/index.html
• Common taskshttp://developer.android.com/resources/faq/commontasks.html