CO838 Internet of Things /: Mobile

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

The UK’s European university

CO838 Internet of Things /


Mobile (1)

Ian Utting
Web App or Native App?

http://xkcd.com/1174/
Web App or Native App?

Web App Native App


• Develop once, deploy • Need to develop for
everywhere each platform
• No revenue-sharing • Easy purchase through
with platform owner app stores
• Cross-platform UI • Platform-specific UI
provides consistency provides consistency
for the app with other apps
• Separation from other • Communication with
apps other apps
Richer web sites: new Javascript APIs

• Media audio and video capture/display


• Touch events: direct support for multi-touch
(otherwise represented as a Mouse event)
• Local storage (for name/value pairs) which can
survive browser sessions
• Local SQL databases and application caches
for offline use
• Geolocation best-effort where am I?
Geolocation example

<script>
var x=document.getElementById("demo");

function getLocation() {
if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  else{x.innerHTML="Geolocation not supported by this browser.";}
}

function showPosition(position) {
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
From W3Schools
Geolocation information

• Uses data from (with typical accuracy values):


• IP address lookup (100m, but often very wrong)
• WiFi signal strengths (50m)
• GSM base-station signal strengths (500m? depending on
tower density)
• GPS data (5m horizontal, much worse vertically)
• Resolved to a geographic address through Microsoft or
Google Location Services
• Requires explicit user approval (for privacy/security)
• Latitude, Longitude & Altitude
• Accuracy estimates.
• “High accuracy” option requests (e.g.) GPS data
• Heading & Speed – Heading only if speed != 0
Android Architecture
Android Application Framework

• Views
• UI elements
• Content Providers
• Enable data sharing between applications
• Resource Manager
• Provides access to non-code resources
• Notification Manager
• Enables applications to display alerts, status
messages, etc
• Activity Manager
• Manages lifecycles of activities
Applications (1)

• Written in “Java”, using some Java SE (java.net,


java.io, java.util collections), some org.apache
and many android-specific libraries
• Compiled to Dalvik bytecode (like Java byte
code, but based on a register-transfer machine,
rather than Java’s stack-machine)
• Bundled with resource and data files in an
Android package (apk)
• Applications run in their own isolated Linux
process
• Started and shutdown as needed
• Each process has a unique Linux user ID
• Files are not visible to other processes
Applications (2)

• An app is a collection of components


• No single entry point – no main()
• May use components from other apps
via their published interfaces
• App components are started when
needed
• Thus, anything from re-skinning to
composing new apps from several
existing ones is possible
Application Components

• Activity
• User interface (composed of Views) for a single task
• App may use several Activities
• Service
• Background process, no UI
• May be used by several apps
• Broadcast Receiver
• Receives/acts on notifications
• Intent
• Used to activate Activities, Services and Broadcast
Receivers
• Content Provider
• Makes data available to other apps, typically from an
on-device SQLite database
The Manifest file

• All application packages (apk’s)


include an AndroidManifest.xml file
• Declares components
• Names required libraries
• Lists permissions required
• Associates components with intents
• Says how each intent should be
invoked (e.g. by the Launcher)
• Specifies icons and labels for display
to the user

You might also like