bruce scharlau, university of aberdeen, 2010 android ui, and networking mobile computing based on...
TRANSCRIPT
![Page 1: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/1.jpg)
Bruce Scharlau, University of Aberdeen, 2010
Android UI, and Networking
Mobile Computing
Based on android-sdk_2.2
Unless otherwise stated, images are from android sdk
![Page 2: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/2.jpg)
Proxy issues while in eduroamMay need page as intermediary for accessing
other services with emulator in Java ME or Android
Bruce Scharlau, University of Aberdeen, 2010
PHP/JSP page
Desired web service
web form can be configured to use proxy
![Page 3: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/3.jpg)
Can do most networking on Android
Bluetooth only on 2.0 onwards – look at that later.
Bruce Scharlau, University of Aberdeen, 2010
![Page 4: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/4.jpg)
Bruce Scharlau, University of Aberdeen, 2010
Android has many components
![Page 5: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/5.jpg)
All layouts are hierarchical
Bruce Scharlau, University of Aberdeen, 2010
![Page 6: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/6.jpg)
All screens
are derived
from view
Bruce Scharlau, University of Aberdeen, 2010Source: unlocking android, p 71
![Page 7: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/7.jpg)
Hierarchical views can include similar groups
Bruce Scharlau, University of Aberdeen, 2010
![Page 8: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/8.jpg)
Children do as told in Android
Bruce Scharlau, University of Aberdeen, 2010
TextView is child of parent viewgroup and fills, or wraps content
![Page 9: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/9.jpg)
There are many types of controls in Android
Bruce Scharlau, University of Aberdeen, 2010
![Page 10: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/10.jpg)
Lists can be handled via adapters and filled from xml file of values
Bruce Scharlau, University of Aberdeen, 2010
![Page 11: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/11.jpg)
Table layout allows for just that with data
Bruce Scharlau, University of Aberdeen, 2010
![Page 12: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/12.jpg)
Use the hierarchy viewer tool to optimize and debug interface
Bruce Scharlau, University of Aberdeen, 2010
http://developer.android.com/guide/developing/tools/hierarchy-viewer.html
![Page 13: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/13.jpg)
Views are tied to activities (screens) in Android
Bruce Scharlau, University of Aberdeen, 2010
Source: unlocking android, p 60
One class per activity, and screen, which may be done as xml file
![Page 14: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/14.jpg)
One layout per activity (class)
Bruce Scharlau, University of Aberdeen, 2010
main.xml goes with AuctionStart
list.xml goes with ListItems
hit_server.xml goes with HitServer
![Page 15: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/15.jpg)
Xml layout file details components
Bruce Scharlau, University of Aberdeen, 2010
Hierarchy of views as noted earlier
![Page 16: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/16.jpg)
Xml layout inflated in onCreate
Bruce Scharlau, University of Aberdeen, 2010
Set value of inflated objectSet value of inflated object
INCOMPLETE CODEINCOMPLETE CODE
New view items and attached to xml valuesNew view items and attached to xml values
![Page 17: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/17.jpg)
Bruce Scharlau, University of Aberdeen, 2010
Android emulator runs as ‘localhost’, ie ‘loopback’
Emulator is at 127.0.0.1 so need to call service at IP address of service to test network apps on developer machine
http://developer.android.com/guide/developing/tools/emulator.html
![Page 18: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/18.jpg)
Bruce Scharlau, University of Aberdeen, 2010
Activity is one thing you can do
From fundamentals page in sdk
![Page 19: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/19.jpg)
Apps move through states during lifecycle
Bruce Scharlau, University of Aberdeen, 2010Source: unlocking android, p 68
onPause is last state to preserve state and cleanup before app possibly destroyed
![Page 20: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/20.jpg)
Handler class provides access to running thread for main UI
Bruce Scharlau, University of Aberdeen, 2010
Handler has Looper which contains MessageQueue that can be called and return objects to UI thread
![Page 21: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/21.jpg)
Handler puts thread response into UI thread
Bruce Scharlau, University of Aberdeen, 2010Source: unlocking android, p 180
![Page 22: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/22.jpg)
Method returns string from network
Bruce Scharlau, University of Aberdeen, 2010
Log output for debugging, etc
Simple method to call URL and return value
![Page 23: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/23.jpg)
Might need helper calls to network
Bruce Scharlau, University of Aberdeen, 2010
Put heavy lifting work in HTTPRequestHelper so accessible to other classes
Handler waits for message and then returns
![Page 24: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/24.jpg)
Parse xml response and populate Java bean instance
Bruce Scharlau, University of Aberdeen, 2010
![Page 25: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/25.jpg)
Add permissions to manifest for connection and network
Bruce Scharlau, University of Aberdeen, 2010
![Page 26: Bruce Scharlau, University of Aberdeen, 2010 Android UI, and Networking Mobile Computing Based on android-sdk_2.2 Unless otherwise stated, images are from](https://reader036.vdocument.in/reader036/viewer/2022062318/5515d88b550346d46f8b4990/html5/thumbnails/26.jpg)
Summary
• Need to provide permissions for network in manifest
• Create tree of xml views for UI
• Can re-use xml views for different displays
Bruce Scharlau, University of Aberdeen, 2010