CS378 - Mobile Computing Web - WebView and Web Services.

Slides:



Advertisements
Similar presentations
® Microsoft Office 2010 Browser and Basics.
Advertisements

Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
Cosc 4755 Blackberry and Android Embedding the browser in your app.
JavaScript ICW: Lecture 11 Tom Chothia. Last Lecture URLs Threads, to make a process run in parallel: Make it extend Thread Give it a run method Call.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
CHAPTER 3&4 ZHONGWEI LI TouchDevelop Book. What are we covering Review of Chapter 1-2 TouchDevelop as a scripting language: actions, events, table and.
Presented by Mina Haratiannezhadi 1.  publishing, editing and modifying content  maintenance  central interface  manage workflows 2.
Application for Internet Radio Directory 19/06/2012 Industrial Project (234313) Kickoff Meeting Supervisors : Oren Somekh, Nadav Golbandi Students : Moran.
Presented by…. Group 2 1. Programming language 2Introduction.
JQuery CS 268. What is jQuery? From their web site:
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Networking Nasrullah. Input stream Most clients will use input streams that read data from the file system (FileInputStream), the network (getInputStream()/getInputStream()),
Adobe Dreamweaver CS3 Revealed CHAPTER ONE: GETTING STARTED WITH DREAMWEAVER.
WaveMaker Visual AJAX Studio 4.0 Training Studio Overview.
JavaScript & jQuery the missing manual Chapter 11
CS378 - Mobile Computing Web - WebView and Web Services.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Server-side Scripting Powering the webs favourite services.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Concurrency in Android with.
Lesson 4: Using HTML5 Markup.  The distinguishing characteristics of HTML5 syntax  The new HTML5 sectioning elements  Adding support for HTML5 elements.
Windows Internet Explorer 9 Chapter 1 Introduction to Internet Explorer.
Windows Internet Explorer 9 Chapter 1 Introduction to Internet Explorer.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Chapter 2 Developing a Web Page. A web page is composed of two distinct sections: –The head content –The body Creating Head Content and Setting Page Properties.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Networking: Part 2 (Accessing the Internet). The UI Thread When an application is launched, the system creates a “main” UI thread responsible for handling.
DUE Hello World on the Android Platform.
Chapter 5 HTTP Request Headers. Content 1.Request headers 2.Reading Request Headers 3.Making a Table of All Request Headers 4.Sending Compressed Web Pages.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Enabling High-Quality Printing in Web Applications
Problem Statement: Users can get too busy at work or at home to check the current weather condition for sever weather. Many of the free weather software.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
CS378 - Mobile Computing Responsiveness. An App Idea From Nifty Assignments Draw a picture use randomness Pick an equation at random Operators in the.
Android networking 1. Network programming with Android If your Android is connected to a WIFI, you can connect to servers using the usual Java API, like.
NOAA Weather Patrick Wolfram. What it does Allows user to specify a zip code Performs HTTP GET requests on noaa.gov for the specified zip code Displays.
Webview and Web services. Web Apps You can make your web content available to users in two ways in a traditional web browser in an Android application,
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
ICM – API Server & Forms Gary Ratcliffe.
Creating Animations, Working with Graphics, and Accessing Data Lesson 9.
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
Users are moving towards web applications Content on the web is more personal & meaningful Development on the web is easier than the OS.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Web APIs By Behrooz and Corey mins... Punch It!! We will give a brief overview of the following topics: WebView WebSettings WebViewClient WebChromeClient.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
Microsoft Office 2008 for Mac – Illustrated Unit D: Getting Started with Safari.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Cosc 5/4730 Embedding the browser in your app. Embedding the browser For many applications, you may not nothing more then the web browser – But you want.
Creating Web Pages with Links, Images, and Embedded Style Sheets
Leveraging Web Content Management in SharePoint 2013 Christina Wheeler.
Secure Mobile Development with NetIQ Access Manager
COMP 143 Web Development with Adobe Dreamweaver CC.
/16 Final Project Report By Facializer Team Final Project Report Eagle, Leo, Bessie, Five, Evan Dan, Kyle, Ben, Caleb.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
Finally getting to html and CSS… Tim Berners-Lee, the writer of the software program that makes him the inventor of the WWW, defines the Internet as a.
Android Application Web 1.
Section 13 - Integrating with Third Party Tools
WebView and Web Services
Persistence - Web Based Storage
Testing REST IPA using POSTMAN
CS371m - Mobile Computing Responsiveness.
Presentation transcript:

CS378 - Mobile Computing Web - WebView and Web Services

WebView A View that display web pages – basis for creating your own web browser – OR just display some online content inside of your Activity Uses WebKit rendering engine – 2

WebView Android 4.4, API level 19 added an alternative to WebKit Chromium "Chromium WebView provides broad support for HTML5, CSS3, and JavaScript. It supports most of the HTML5 features available in Chrome for Android 30. It also brings an updated version of the JavaScript Engine (V8) that delivers dramatically improved JavaScript performance. " 3

WebView Built in functionality to: display page navigate forward and backwards through a history zoom in and out perform searches and more: – capture images of page, search page for string, deal with cookies on a per application basis, 4

More on WebView Scenarios for using WebView in app instead of built in browser: provide info the app might need to update such as end user agreement or user guide (instead of doing app update) – display documents hosted online OR application provides data that ALWAYS requires internet connect to retrieve data – as opposed to performing network request and parsing data to display in Android layout OR display ads (blah) ew.html 5

WebView Example Simple app to view and navigate web pages - demo WebView class res/layout/main.xml 6

WebView Activity override onCreate go to UT mobile site 7

WebView Example Must add permission for app to use Internet Also change style so no title bar 8

Current Result 9 Clicking link actually leads to the default Android browser

Handling URL Requests To enable activity to handle its own URL requests create an inner class that extends WebViewClient set client for mWebView 10

Navigating Making previous changes disables the back button Must override onKey down method Use WebView object to see if possible to go back 11

Using Built In Browser To simply use the built in browser create an Intent and start the Activity Like the Top Ten List App 12

WEB SERVICES 13

Web Services "Web services are a means of exposing an API over a technology-neutral network endpoint. They are a means to call a remote method or operation that's not tied to a specific platform or vendor and get a result." – Android in Action 3 rd edition 14

Web Services Sources /directory/1?sort=mashups /directory/1?sort=mashups 15

Flickr API 16

Flickr API Methods create url using API method name and parameters, plus api key 3 request formats – REST – XML-RPC – SOAP Multiple Response Formats 17

Flickr API Methods 18

Sample Request URL ?method=flickr.photos.search &api_key=754a89ad04e0b72f42ffb77f41 2c021e &tags=blue,cool,pretty 19

Result 20

Parse Result to URL for Picture 21

Photo URL and Result _ d3.jpg 22

Flickr Example 23

JSON Format Flickr allows request for response format – one example, JSON 24

WEATHER BUG EXAMPLE 25

WeatherBug Example From Deitel Android Programmers: An App-Driven Approach Example for Tablets – Fragments – tabbed navigation in Action Bar – Widget for home screen Our focus is on the use of Web Services 26

WeatherBug API 27

WeatherView App - Current 28

WeatherView App - Five Day 29

Use of API most API's require registration and a key value key used in requests 30

WeatherBug Web Services Three classes deal with making requests via the WeatherBug API in WeatherView ReadLocationTask – use zip to get location information ReadForecastTask – read current forecast for given zip code ReadFiveDayForecastTask – get forecast for next five days for given zip 31

Tasks All three class extend AsyncTask constructors override doInBackground method override onPostExecute method define their own listeners Keep the UI thread responsive by using AsyncTask to perform potentially slow tasks 32

AsynchTask "AsyncTask allows you to perform asynchronous work on your user interface. It performs the blocking operations in a worker thread and then publishes the results on the UI thread, without requiring you to handle threads and/or handlers yourself."AsyncTask Task started by invoking the execute method roid/os/AsyncTask.html 33

ReadLocationTask Created with Context, zip code, and Listener Listener updated in postExecute method 34

ReadLocationTask - doInBackground Creates URL using zip and API key 35

JSON JavaScript Object Notation a way to represent JavaScript objects as Strings alternative to XML for passing data between servers and clients designed for data interchange format that humans can also read and write 36

JSON Format Built on two structures – collection of name-value pairs: a.k.a. objects, records, structs, etc. – an ordered list of values: a.k.a. an array objects 37

JSON Format arrays values – string, number, object, array, true, false, null 38

JSON Values 39 Syntax Diagrams for string and number:

JSON Strings 40

JSON Numbers 41

JSON Examples value (String): – "Round Rock" array: – ["Round Rock", "Dallas", "Houston"] object – {"height":70,"weight":165} 42

Results For ReadLocationTask GetLocation.ashx?zip=78681&api_key=xxx xx GetLocation.ashx?zip=78681&api_key=xxx xx – where xxxxx is your API key Result: – {"location":{"city":"Round Rock","cityCode":null,"country":"United States","dma":"635","isUs":true, "lat": ,"lon": , "state":"TX","zipCode":"78681"}} 43

Parsing JSON JsonReader class in Android API Read JSON encoded values as a stream of tokens ReadLocationTask uses a JsonReader to parse the JSON returned by the web request Pulls out city, state, and country string to display in View 44

Creating JsonReader and check given zip returns a valid location 45

Reading Location Data 46

onPostExecute Send the city, state, and country data to the listener 47

ReadForecastTask Similar in nature to ReadLocationTask, but different url for different data {"forecastHourlyList": [{"chancePrecip":"10","dateTime": , "desc":"PartlyCloudy","dewPoint":64,"feelsLike":73, "feelsLikeLabel":"Heat Index","humidity":"74", "icon":"cond002","skyCover":null, "temperature":73,"windDir":null,"windSpeed":10}, {"chancePrecip":"10","dateTime": , "desc":"Partly Cloudy","dewPoint":64,"feelsLike":70, "feelsLikeLabel":"Heat Index","humidity":"81", "icon":"cond002","skyCover":null, "temperature":70,"windDir":null,"windSpeed":11}, and on for another 158 hours 48

ReadForecastTask Also downloads image for current condition 49

Icons Obtained From WeatherBug 50

ReadFiveDayForecastTask {"dateTime": , "dayDesc":"Partly Cloudy","dayIcon":"cond003", "dayPred":"Cloudy in the morning...becoming partly cloudy. Patchy fog in the morning. Highs 61 to 66. Light winds becoming west 15 mph with gusts to 25 mph in the afternoon.", "dayTitle":"Wednesday","hasDay":true, "hasNight":true,"high":"66","hourly":null,"low":"54","ni ghtDesc":"Drizzle","nightIcon":"cond162", "nightPred":"Partly cloudy in the evening...becoming cloudy. Patchy fog and patchy drizzle overnight. Lows 49 to 55. Areas of winds northwest 15 to 20 mph with gusts to 25 mph in the evening becoming light.", "nightTitle":"WednesdayNight","title":"Wednesday"}, 51

Displaying Data App does not try and display all data, just chooses "most important" icon day of week day prediction high temp low temp 52