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
Proxy issues while in eduroam May 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
Can do most networking on Android Bluetooth only on 2.0 onwards – look at that later. Bruce Scharlau, University of Aberdeen, 2010
Android has many components
All layouts are hierarchical Bruce Scharlau, University of Aberdeen, 2010
All screens are derived from view Bruce Scharlau, University of Aberdeen, 2010 Source: unlocking android, p 71
Hierarchical views can include similar groups Bruce Scharlau, University of Aberdeen, 2010
Children do as told in Android Bruce Scharlau, University of Aberdeen, 2010 TextView is child of parent viewgroup and fills, or wraps content
There are many types of controls in Android Bruce Scharlau, University of Aberdeen, 2010
Lists can be handled via adapters and filled from xml file of values Bruce Scharlau, University of Aberdeen, 2010
Table layout allows for just that with data Bruce Scharlau, University of Aberdeen, 2010
Use the hierarchy viewer tool to optimize and debug interface Bruce Scharlau, University of Aberdeen,
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
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
Xml layout file details components Bruce Scharlau, University of Aberdeen, 2010 Hierarchy of views as noted earlier
Xml layout inflated in onCreate Bruce Scharlau, University of Aberdeen, 2010 Set value of inflated object INCOMPLETE CODE New view items and attached to xml values
Bruce Scharlau, University of Aberdeen, 2010 Android emulator runs as localhost, ie loopback Emulator is at so need to call service at IP address of service to test network apps on developer machine
Bruce Scharlau, University of Aberdeen, 2010 Activity is one thing you can do From fundamentals page in sdk
Apps move through states during lifecycle Bruce Scharlau, University of Aberdeen, 2010 Source: unlocking android, p 68 onPause is last state to preserve state and cleanup before app possibly destroyed
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
Handler puts thread response into UI thread Bruce Scharlau, University of Aberdeen, 2010 Source: unlocking android, p 180
Method returns string from network Bruce Scharlau, University of Aberdeen, 2010 Log output for debugging, etc Simple method to call URL and return value
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
Parse xml response and populate Java bean instance Bruce Scharlau, University of Aberdeen, 2010
Add permissions to manifest for connection and network Bruce Scharlau, University of Aberdeen, 2010
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