Android UI, and Networking

flosssnailsΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 2 χρόνια και 10 μήνες)

55 εμφανίσεις

Android UI, and Networking

Can do most networking on

Bluetooth only on 2.0,

Not supported with version 1.6

Bruce Scharlau, University of Aberdeen, 2009

Android has many components

Bluetooth and USB drivers now gone from kernel

XMPP gone from application framework

All layouts are hierarchical

from view

Hierarchical views can include
similar groups

Children do as told in Android

TextView is child of parent viewgroup and fills,
or wraps content

There are many types of
controls in Android

Lists can be handled via adapters
and filled from xml file of values

Table layout allows for just that
with data

Use the hierarchy viewer tool to
optimize and debug interface

Views are tied to activities
(screens) in Android

One class per
activity, and
screen, which
may be done
as xml file

One layout per activity (class)

main.xml goes with AuctionStart

list.xml goes with ListItems

hit_server.xml goes
with HitServer

Xml layout file details components

Hierarchy of views
as noted earlier

Xml layout inflated in onCreate

Set value of inflated object


New view items and attached to
xml values

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

Bruce Scharlau, University of Aberdeen, 2009

Activity is one thing you can do

Apps move through states
during lifecycle

onPause is last state
to preserve state and
cleanup before app
possibly destroyed

Handler class provides access
to running thread for main UI

Handler has Looper which
contains MessageQueue that
can be called and return
objects to UI thread

Handler puts thread response
into UI thread

Method returns string from network

Bruce Scharlau, University of Aberdeen, 2009

Log output for debugging, etc

Simple method to call URL and return value

Might need robust calls to network

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, 2009

Add permissions to manifest for
connection and network

Bruce Scharlau, University of Aberdeen, 2009

End of Lecture