If you can't read please download the document
Upload
-
View
22
Download
0
Embed Size (px)
Citation preview
- 02403
2012
-i-
-ii -
:
:
1.
2.
3.
-iii -
smartphones
o
o
o
server-side Android
.
,
30/06/2012
-v-
........................................................................................................................... III
...................................................................................................................... V
1 .......................................................................................................................... 1
2 SMARTPHONES ............................................................................................................... 3
2.1 ....................................................................................................... 3
2.2 ............................................................................................ 4
2.2.1 Windows Phone ............................................................................................ 4
2.2.2 iOS .................................................................................................................. 6
2.2.3 Android ........................................................................................................... 8
2.2.4 ................................................................... 14
2.3 ANDROID ......................................................................................... 14
2.3.1 ............................................................................................. 15
2.3.2 (Native Libraries) ................................................... 16
2.3.3 (Android Runtime) ...................................................... 16
2.3.4 (Application Framework) ......................................... 16
2.3.5 Widgets ............................................................................. 17
2.4 ANDROID; .......................................................................................................... 18
3 ANDROID ............................................................................... 19
3.1 ................................................................... 19
3.2 ..................................................................................... 19
3.3 ............................................................................ 19
3.3.1 ............................................................................................... 20
3.3.2 Android SDK Manager AVD Manager ............................................... 22
3.3.3 Project ...................................................................................... 25
3.4 ANDROID ...................................................................... 26
3.4.1 ................................................................................................. 26
3.4.2 ................................................................................................ 26
3.4.3 .................................................................................................... 26
-vi-
3.4.4 ........................................................................................... 27
3.4.5 ............................................................................................... 27
3.4.6 AndroidManifest.xml ................................................................................... 29
3.5 ANDROIDMANIFEST.XML ...................................................................................... 29
4 ............................................................. 33
4.1 ...................................................................................... 33
4.2 ................................................................................................... 33
4.3 ............................................................................................ 35
4.4 SERVER ..................................................................................... 39
4.4.1 .......................................................................... 39
4.4.2 ................................................................ 42
4.5 ............................................................................................... 43
4.5.1 .............................................................................................. 44
4.5.2 ............................................................. 48
4.5.3 .............................................................................. 50
4.5.4 ......................................................................... 52
4.6 OFF-LINE ..................................................................................... 54
5 GASFINDER ............................................................................................ 59
5.1 ............................................................................................................. 59
5.2 ......................................................................................... 59
5.3 ................................................................................................... 59
5.4 ........................................................................................... 61
5.5 ............................................................................................................. 62
5.6 ..................................................................................................................... 63
5.7 OFF-LINE ..................................................................................... 64
5.8 ...................................................................................... 65
6 ........................................................................................................... 67
..................................................................................................................... 69
...................................................................................................................... 71
......................................................................................................................... 73
-1-
1
Smartphones
,
,
.
.
smartphones
Android
-3-
2 Smartphones
2.1
Smartphones
. Smartphones
PDA (Personal Digital Assistant)
e-mail ,
.
.
Social Media Facebook, Twitter Google+.
smartphones
smartphones
.
RA
GPS
iOS, Android, Windows Phone Symbian,
.
-4-
2.2
hardware
Android Google,
iOS Apple Windows Phone Microsoft
Symbian Nokia Ericsson Palm Os Garnet
OS RIM Blackberry OS.
iPhone
iPhone
Android
, hardware
Android
Android
Windows Phone
Windows Phone 8
Mi-
crosoft Microsoft
.
2.2.1 Windows Phone
Windows Phone ( 2.1)
Microsoft Windows Mobile.
-5-
Windows Phone Microsoft
Metro
Microsoft, .
2.1 Windows Phone
Windows Mobile Photon
project Microsoft
Windows Phone
Microsoft Windows Mobile 6.5 Win-
dows Phone
Windows Mobile.
Windows Phone
Microsoft Windows Mobile
Microsoft Win-
dows Mobile Windows Phone Win-
dows Phone 7 Series
Windows Phone 7.
Microsoft Mobile Word Congress
Windows Phone MIX 2010.
CEO Microsoft Steve Ballmer
Windows Phone HTC, Dell, Samsung LG.
Nokia Windows Phone
-6-
Nokia.
C++.
Windows Phone.
Windows Phone OS.
7.0.7008
7.0.7390 NoDo CDMA,
Mango .
7.10.7720 Windows Phone 7.5 Mango
mobile
Internet Explorer 9, multi-tasking Windows Live Sky Drive
e-mail Microsoft Exchange Server
2003
Windows Phone Tango
o NoDo Windows Phone
RAM 256Mb.
2.2.2 iOS
To iOS iPhone OS Apple
(Error! Reference source not found.). Ap-
ple iPhone
Apple. Mac OS
Unix. Objective-C ( C) Cocoa
Touch API.
Apple iPhone
OS X .
-7-
beta SDK
iPhone OS .
iPhone OS iOS
Apple iOS CISCO
router
iOS iOS
iOS iPad.
To iOS iPhone iPod Touch
bugs
iOS 4.2 iOS 4.2.1
iPad.
iOS CDMA.
H iOS iPhone
CDMA.
H iOS
CDMA
iOS 4.2.x iOS
iOS bugs
iOS iOS developers.
2.2
-8-
2.2.3 Android
Linux Android ( 2.3)
smart phones
Java
Google . H
Google Open Handset Alliance.
Open Handset Alliance
hardware (Google, HTC, Samsung,
Motorola, AT&T, Verizon
Android Apache License
2.3 Android
Android
HTC Dream (
T-Mobile G1) T-Mobile.
Google SDK Release Candidate 1.0.
Android 1.5
Cupcake ( 2.4). Cupcake
(User Interface).
-9-
mode.
tube
.
2.4 Cupcake
Android 1.6 Donut ( 2.5)
2.5 Donut
Android Market.
Gallery.
voice search.
.
-10-
CDMA/EVDO, 802.1x, VPNs, text-to-speech.
Gesture framework Gesture Builder.
turn-by-turn Google.
Android 2.0 Eclair ( 2.6)
Android 2.0.1 (Eclair 0.1) Android 2.1 (Eclair MR1)
hardware.
.
Browser
Contrast Ratio Backgrounds
Google Maps 3.1.2
Microsoft Exchange Server, ActiveSync 2.5
Flash
zoom.
Multi -Touch.
Bluetooth 2.1.
Live Wallpapers.
2.6 Eclair
Android 2.2 Froyo ( 2.7)
-11-
Chrome V8 JavaScript Browsers .
.
Application Launcher
Browser.
USB Tethering Wi-Fi Hotspot.
(Data Access over
Mobile Network).
Market updates.
Adobe Flash 10.1.
DPI .
2.7 Froyo
Android 2.3 Gingerbread ( 2.8)
Android 2.3.3
Design.
.
VoIP Telephony.
Playback Audio Encoding.
-12-
reverb, equalization, headphone virtualization, bass
boost.
-Touch .
.
Development.
Developers
Download Manager
file system.
2.8 Gingerbread
Android 3.0 Honeycomb ( 2.9)
2.9 Honeycomb
-13-
3D, Render script
Video Chat Google Talk.
Google eBooks.
Android 4.0 Ice Cream Sandwich ( 2.10)
(Face Unlock).
(Panorama Mode).
NFC (Android
Beam).
Web
e-mail (
internet (Offline mode
(People App).
Notification Center.
(Recent Apps).
2.10 Ice Cream Sandwich
Android
2.11 Froyo -
-14-
2.11 Android
2.2.4
Symbian Os RIM Blackberry OS. To Symbian OS
EPOC PSION
Symbian Ltd C++. 2008 Symbian
Foundation Symbian Ltd. Symbian OS
Nokia, Sony Ericsson ( Sony), Benq-
Siemens, Samsung, Motorola, NTT DoCoMo. Symbian OS
Nokia Series 60, Series 80, Series 90, UIQ FOMA.
smartphones Blackberry OS BlackBerry smartphone
Research In Motion
(RIM) PDA
C++
Java.
2.3 Android
Android
Linux
-15-
Android
An-
droid 2.12.
2.12 Android OS
2.3.1
To Linux 2.6 (Linux Kernel)
Android.
Wi-Fi Flash,
-16-
2.3.2 (Native Libraries)
C C++
interface Java.
Surface Manager
2D) (3D)
Media Framework (codecs)
mp2,mpeg
SQLite
SQL.
Web Kit
(browsers).
2.3.3 (Android Runtime)
Java
Dalvik Virtual Machine
Android Java
Dalvik VM
(Dalvik Executable) dex) dex VM
2.3.4 (Application Framework)
Application Framework
Application Framework
-17-
Content Providers:
Notification Manager Status Bar.
Activity Manager ( 2.13).
Resource Manager
View System:
2.13
2.3.5 Widgets
widgets
widget
.
-18-
2.4 Android;
. Android
open-source
.
-19-
3 Android
3.1
Android.
Android
.
Android.
(
.
3.2
Android Java.
C++.
NDK (Native Development Kit )
C & C++ Java Android.
3.3
Eclipse IDE, An-
droid SDK, ADT Plug In for Eclipse JDK.
-20-
3.3.1
JDK
( 3.1) Oracle .
3.1 JDK Download
Android An-
droid SDK ( 3.2). (Android SDK)
Win-
dows SDK Android SDK Manager.
API .
API Google API 10
(Android 2.3.3)
http://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://developer.android.com/sdk/index.html-21-
3.2 Android SDK Download
Eclipse Eclipse
Classic 3.7.1 ( 3.3). Eclipse
Help Install New Software.
Work With ADT Plug In ,
Developer Tools 3.4
3.3 Eclipse Download
http://www.eclipse.org/downloads/-22-
3.4 ADT Plug In Install
AVD Manager .
AVD Manager
Android.
3.3.2 Android SDK Manager AVD Manager
Android SDK Manager
AVD Manager. Android SDK Manager 3.5
Android
extra. Android SDK Tools Android SDK Plat-
form Tools.
-23-
Android
API. To API Application Programming
Interface,
API
SDK Platform API. Samples For SDK
Google APIs by Google Inc
API Android
Android
. Ice Cream
Sandwich API 14) Gingerbread
(API 10). T Ice
Cream Sandwich API 14) Gingerbread (API 10).
Google API
.
extra
Google Analytics SDK
Google Ad-
mob ADS SDK
3.5 Android SDK Manager
-24-
Android Virtual Device Manager ( 3.6)
3.6 AVD Manager
Name
Target (API)
CPU/ABI:
.
SD Card:
Snapshot:
AVD
-25-
Skin:
Hardware: RAM
3.3.3 Project
Project Eclipse
Project
3.7 Android Project
1. Eclipse File New(Alt + Shift + N) Project
Android Project Next 3.7.
2. Project Name Project
Next .
3.
-26-
4. Application Name , Minimum
SDK API
Package Name .
5. Finish Eclipse
3.4 Android
Eclipse Project
3.4.1
src Source
3.4.2
gen
Project (Package Name).
3.4.3
*.jar Java Ar-
chive)
Java
Android
Android Google APIs Android ,
Google APIs [Android 2.3.3] .
-27-
3.4.4
Assets
3.4.5
res (res
resources) .
xml, raw
Res o
1
XML
1 Android
XML
/res/values/ strings.xml
/res/values/ strings.xml ,
/res/values/ strings.xml ,
Boolean /res/values/ bools.xml
/res/values/ Colors.xml
/res/color/
buttonstates.xml
indicators.xml
,
/res/values/ dimens.xml
/res/values/ integers.xml
/res/values/ integers.xml ,
-28-
/res/values/ arrays.xml ,
/res/values/ drawable.xml
/res/drawable/
icon.png, logo.jpg XML
tween /res/anim/
fadesequence.xml
spinswquence.xml
, , ,
,
/res/drawable/
sequence1.xml
sequence2.xml
,
/res/menu/
mainmenu.xml
helpmenu.xml
XML /res/xml/
data.xml, data2.xml
/res/raw/
jingle.mp3,somvideo.mp4,
helptext.txt
/res/layout/
main.xml,help.xml
.
/res/values/ styles.xml
themes.xml( )
-29-
3.4.6 AndroidManifest.xml
AndroidManifest.xml
3.5 AndroidManifest.xml
AndroidManifest.xml (/root)
project
Android
Java
ID
(activities),
(services), (broadcast receivers)
(Intents
messages) Android
.
API
Instrumentation Classes
Android API
AndroidManifest.xml
3.8
-30-
3.8 AndroidManifest.xml
AndroidManifest.xml
:
xml version xml encoding
,
, .
3.8
.
gr.gasFinder.bazpap.
android:versionCode
android:VersionName:
-31-
-33-
4
4.1
.
Offline
4.2
-34-
server.
Off-line 4.6).
4.5.4).
server 4.4).
splash.xml
Main.java splash.xml 4.1
,
& 4) .
4.1 XML
Main.java
( 4.2)
23). isInternetOn 2-44
Offline
startService
.
server
server
4.5.4 4.4
connectivityManager
( 3
4-42
G ( getNetworkInfo wi-fi ( getNetworkInfo
true
-35-
false
( 4.15
4.2 Main
4.3
background
xml Pref-
erences
xml radiusList.xml
typeLlist.xml
-36-
timeList.xml
xml
4.3.
4.3 XML
xml preferences.xml ( 4.4)
xml
(listPreference) xml
(android:entries &
android:entryValues ).
(android: defaultValue ),
(android: key) , (android: selectable
(android: summary (android: title
PreferenceScreen checkbox
checkboxes(
checkbox
android : disableDependentsState =" true
checkboxes
checkbox android:dependency="all" .
-37-
4.4 XML
xml (
4.5).
( 9).
onCreate() .
setCon-
-38-
tentView
4) layout
preferences.xml
SharedPreferences Android SharedPreferences
10
getSharedPreferences 31 & 32
SharedPreferences.Editor
33)
editor commit() .
4.5 Preferences
-39-
onBackPressed 8-27
save 9-46,
save Map
-23)
server & 25)
.
Preferences
4.4
server
.
. org.apache.http
HTTP Android (HoneyComb)
AsyncTask (Asynchronous task)
4.6 ServerConnection.
4.4.1
AsyncTask
doInBackground onPreExecute onPostExecute
onPreExecute ( )
doInBackground
-40-
onPostExecute ( ).
AsyncTask .
AsyncTask.
Void
execute
4.6 ServerConnection()
server ServerCon-
nection AsyncTask. constructor
Context ServerConnectionListener
onPreExecute
onPostExecute
-41-
ServerConnectionListener. O ServerConnection-
Listener
nterface 4.7 ServerConnectionListener Interface
Listener
Implements ServerConnectionListener
ServerConnectionComplete 4.8
Main Preferences.
.
4.7 ServerConnectionListener Interface
4.8 ServerConnectionComplete
doInBackground
server. HTTP
HttpClient 56)
HTTP .
HttpPost 57).
mpazigos.dyndns.org .
Post Get .
NameValuePair
-42-
59)
79)
81).
server
87)
ftype ), recency
( , radius ( latitude
& longitude allStationsValue
shellValue, etekaValue, bpValue, jetoilValue, revoilValue, silkoilValue, kaoilValue,
aegeanValue, ekoeldaValue, avinValue, elpetrolValue, elinoilValue, cyclonValue, dra-
coilValue, medoilValue, argoValue, kmoilValue, apValue).
NameValuePair add(new BasicNameValuePair("
", " ")) 62).
4.4.2
XML
DTD.
DTD XML
XML ,
DTD 4.9. stations
gasstation
( ,
. (
PCDATA ,
-43-
4.9 Document Type Definition
DTD DTD
, XML ( 4.10)
DTD XML ( 2).
XML DTD XML
4.10 DTD XML
4.5
-
server,
.
.
-44-
4.5.1
Google Maps.
MD5
Map API Key
Obtaining a Maps API Key). Map API
Key
(cmd) bin JDK
keytool .
4.11.
4.11 MD5
keystore
keystore
Eclipse Window-Preferences-Android-Build ( 4.12).
Map API Key
Sign Up for the Android Maps API
Generate API Key
( 4.13).
API Key
( 4.14)
https://developers.google.com/maps/documentation/android/mapkey#getfingerprinthttps://developers.google.com/android/maps-api-signup?hl=el-GR-45-
4.12 Debug Keystore
4.13 API Key
4.14 API Key
-46-
AndroidManifest ( 4.15)
Android
16)
uses-permission application uses-library
4.15 internet
xml
o xml 4.16
ID
4 & 5),
API KEY (
4.16 Map.xml
xml
Java ( 4.17).
Activity
. MapView
.
onCreate()
-47-
( xml
MapView
zoom-in & zoom-out
4.18.
4.17 Map
4.18
-48-
4.5.2
. 4.19.
stations
gasstation
gasstation lat
), long price ( type (
name( address ( owner (
lastUpdate (
4.19 xml
4.20. Error! Re f-
erence source not found. XML
.
XML
Document Object Model (DOM). Docu-
mentBuilder DocumentBuilderFactory Docu-
ment Node , NodeList Element .
( .
DocumentBuilderFactory (
XML
DOM Docu-
mentBuilder (
Document
parse ( .
getDocumentElement ( Element
-49-
stations gasstation
NodeList
gasstation ( .
gasstation
NodeList ( gas-
station
( .
XML String.
( )
XML ) String
.
XML .
4.20
-50-
4.5.3
Off-
line View 4.6
.
. (
( 4.21):
1. MapView .
2. Drawable 73)
3. MyItemizedOverlay
Drawable
MapView
4. GeoPoint
5. OverlayItem
GeoPoint String
6. addOverlay(OverlayItem
3
7.
MyItemizedOverlay
80). Overlay
.
-51-
4.21
4.22.
XML
.
4.22
-52-
4.5.4
server
AsyncTask.
Main
Map
GPS.
UserLocation
4.23.
UserLocation
AsyncTask . Location-
Listener , LocationManager
ProgressDialog .
AsyncTask onPreExecute,
doInBackground onPostExecute.
LocationListener 9) LocationManager
100) LocationManager requestLoca-
tionUpdates LocationListener
107). requestLocationUpdates :
GPS
),
LocationListener.
.
doInBackground
onPostExecute
server
114 116) .
-53-
LocationListener
Loca-
tionListener implement
onLoca-
tionChanged, onProviderDisabled, onProviderEnabled onStatusChanged.
Location
getLatitude getLongitude
.
130)
134) Log
Map UserLocation
onPreExecute
onPostExecute
doInBackground LocationListener
,
GPS
.
.
GPS
GPS
,
.
-54-
4.23 UserLocation
4.6 Off-line
4.2
-55-
Offline
View
Offline View
server
Offline View
4.5.2 String
Offline View
String
xml
layout (list.xml)
(list view) ( 4.24) layout listAdapter
4.24 List View Layout
Android layout listAdapter
-56-
layout mylist.xml 4.25
layout (simple_list_item_1)
layout
4.25 mylist.xml
4.26 Offline
layout
4.26
onCreate()
list.xml ( 6 gasStations
7
null ,
. setListAdapter
3 & 34) layout mylist.xml
-57-
gasStations
\t tab).
\t )
. Offline
Offline.
-59-
5 gasFinder
5.1
.
smartphones
Android.
5.2
GasFinder (Gas
gasoline .
Vehicle )
-
GasFinder
Off-line
5.3
5.1
-60-
server
5.2 .
server.
Off-line
5.1
5.2
-61-
5.4
5.3
( 5.3
5.4
Off-line
5.3
-62-
5.4
5.5
5.5 4.3
( 5.6).
save
5.5
-63-
5.6
5.6
Off-
line
( 5.7).
-64-
5.7
5.7 Off-line
H
( 5.8
5.6
.
4.6
5.8