01 10 351-352...351 ヤマト科学 0120-405-525 恒温・乾燥器/ 恒温恒湿器 産業機器 プラズマ装置 高温炉・ パージガス 恒温培養器 凍結乾燥・ 冷却トラップ
[CCDD2013w] Coming to grips with deving for android by 蔡亦恒
description
Transcript of [CCDD2013w] Coming to grips with deving for android by 蔡亦恒
![Page 1: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/1.jpg)
I-Hen Tsai
Software Engineer
Delta Electronics Tainan Joint Labs
![Page 2: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/2.jpg)
Requirements
Android SDK
Java JDK
Eclipse IDE
Some knowledge of Java programming
A modern computer
Guts
And maybe a beer…
2
![Page 3: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/3.jpg)
Setting up the JDK
Download JDK
from Oracle
http://www.oracl
e.com/technetw
ork/java/javase/
downloads/jdk7
-downloads-
1880260.html
3
![Page 4: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/4.jpg)
Setting up the Android SDK
http://developer.androi
d.com/sdk/index.html
SDK Manager:
\android-sdk-
windows\tools\android.
bat
Update as required
4
![Page 5: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/5.jpg)
Setting up Eclipse IDE
http://www.eclipse.org/
downloads/
Pick a “Eclipse IDE for
Java Developers”
matching your OS
Unpack your download
5
![Page 6: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/6.jpg)
Your new Android project (0)
On boot, Eclipse will ask where to put your
projects (your workspace)
Pick somewhere you wont forget, preferably with a
lot of space
Install ADT plugin & restart Eclipse
https://dl-ssl.google.com/android/eclipse/
6
![Page 7: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/7.jpg)
Your new Android project (I)
Start a new “Android Application Project”
Give it a good name & pick an
appropriate minimum required SDK
7
![Page 8: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/8.jpg)
Your new Android project (II)
Pick a launcher icon
Pick a starting activity
Pick the navigation style
8
![Page 9: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/9.jpg)
Your new Android project (III)
You should get this screen when you are
done
9
![Page 10: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/10.jpg)
Your new Android project (IV)
You can also import an existing project
Menu: ”File”>>”Import”
Select Android project and pick the directory
path for it
10
![Page 11: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/11.jpg)
Basics
Each screen is an “activity”
Activity = code (Java) + UI layout (XML)
Code controls everything
Except modifying UI layouts
UI layout is composed of “widgets”
A button, an image or a textbox are all
widgets
The labels of widgets can be changed by
code
11
![Page 12: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/12.jpg)
Exploring your project
src: code
libs: reference libraries
bin: compiled apk
res: all media, layouts, visuals
res/layout: UI layout of all activities
AndroidManifest.xml: the heart of any Android project
Permissions
Declaring components
12
![Page 13: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/13.jpg)
Debugging with Eclipse
If you want to use your physical device,
remember to turn on USB debugging
Settings >> Developer options >> USB
debugging
Emulation
DDMS
LogCat
13
![Page 14: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/14.jpg)
Setting up an Android emulator (I)
Menu: “Window” >> “Android Virtual
Device Manager”
Select “New”
Select suitable attributes
14
![Page 15: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/15.jpg)
Setting up an Android emulator (II)
Start your virtual device first to save time
15
![Page 16: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/16.jpg)
Emulating your Android
application
Select one of your source files
Select the green “Run [your program name] button
First run only:
Select run as “Android Applicaiton”
Say “Yes” to LogCat, nyan~!
Viola!!
16
![Page 17: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/17.jpg)
Emulating your Android
application (II)
If you didn’t start a virtual device first,
Eclipse will start one for you
Automatically selects first compatible device
Prompts you to create if you don’t have one
But you have to wait for it to boot
Might have to run again because it took too
long for the virtual device to start
17
![Page 18: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/18.jpg)
Testing with other Android
devices
Menu: “Run” >> “Run Configurations…”
Switch to “Target” tab
Choose “Always prompt to pick device”
Now you get to choose a device every
time you run your application
18
![Page 19: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/19.jpg)
DDMS (I)
Menu: “Window”>>”Open
perspective”>>”DDMS”
19
![Page 20: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/20.jpg)
DDMS (II)
You can do a lot of things in the DDMS
File dump
Fake GPS
Check CPU load
20
![Page 21: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/21.jpg)
LogCat (I)
Menu: “Window”>>”Show
View”>>”Other”>>”LogCat”
A log of everything computational on the
Android device
21
![Page 22: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/22.jpg)
LogCat (II)
You can filter log data by:
Application
Debug level
You can also save the log
You can use code to send debug data to
LogCat
Better than using “push” popup messages
22
![Page 23: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/23.jpg)
Debugging with Android SDK
Same as DDMS
\android-sdk-windows\tools\android.bat
23
![Page 24: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/24.jpg)
Publishing your app
Compile in “release” config
APK file
Mail to people you want to share
Host on website for download
etc.
Publish to Google Play
Need Google account
USD 25 registration fee
24
![Page 25: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/25.jpg)
Tricks for demoing
Make a video capture
Android emulator
BlueStacks
Droid @ Screen
25
![Page 26: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/26.jpg)
BlueStacks
http://www.bluestacks.com/
Install a custom launcher and you are
ready to go
26
![Page 27: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/27.jpg)
Droid @ Screen
http://droid-at-
screen.ribomation.com/
Requires Java & a USB
connection to your
Android device
Just specify where your
/sdk/platform-
tools/adb.exe resides
27
![Page 28: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/28.jpg)
Wrapping it up…
Read the documentation
Ask around on StackOverflow
Plan a lot
Don’t give up
Practice makes perfect!
And remember to have fun
28
![Page 29: [CCDD2013w] Coming to grips with deving for android by 蔡亦恒](https://reader034.fdocuments.us/reader034/viewer/2022052523/555ac74dd8b42a761a8b4eb9/html5/thumbnails/29.jpg)
29