HUJI Post PC Workshop 5 Files, Threading, and Web Services Sasha Goldshtein

Slides:



Advertisements
Similar presentations
Bruce Scharlau, University of Aberdeen, 2010 Android and Location Mobile Computing Unless otherwise stated, images are from android sdk.
Advertisements

Warwick Bailey, Director Icodeon Ltd Cambridge, UK.
CE881: Mobile and Social Application Programming Networking Simon M. Lucas.
Factual.com Location Information. Temporal and Spatial Information Information can have temporal and spatial aspects Examples – The nearest XXX (xxx =
Prepared by: Prepared by: Jameela Rabaya Jameela Rabaya Fatima Darawsha Fatima Darawsha.
USING ANDROID WITH THE INTERNET. Slide 2 Network Prerequisites The following must be included so as to allow the device to connect to the network The.
Web API for Mobile JaxARCSIG April About Me David Fekke L.L.C. Mobile apps for iOS Regular presenter at JaxDUG, JSSUG and JaxFusion Writing Web.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Threads Load new page Page is loading Browser still responds to user (can read pages in other tabs)
Cosc 4730 Brief return Sockets And HttpClient And AsyncTask.
Python for S60 SmartPhones PostPC Workshop Fall 2006 Amnon Dekel.
HTTP and Threads. Download some code I’ve created an Android Project which gives examples of everything covered in this lecture. Download code here.here.
Networking Nasrullah. Input stream Most clients will use input streams that read data from the file system (FileInputStream), the network (getInputStream()/getInputStream()),
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Concurrency in Android with.
Introduction to Windows Store app development for Android programmers
Mobile Programming Lecture 14 Communicating via the Internet.
BETaaS APIs Webinar Adaptation, Service and Extended Service Programming Interfaces 1 H OW TO I NTERACT T HROUGH BET AA S API S.
Google Data APIs Google Data APIs : Integrando suas aplicações Java com os serviços Google.
Networking: Part 2 (Accessing the Internet). The UI Thread When an application is launched, the system creates a “main” UI thread responsible for handling.
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
1 Mobile Software Development Framework: Android 2/28/2011 Y. Richard Yang.
Networking Android Club Networking AsyncTask HttpUrlConnection JSON Parser.
HTTP and Threads. Download some code I’ve created an Android Project which gives examples of everything covered in this lecture. Download code here.here.
Asynchronous Tasks with Android Anthony Dahanne, Ing Jr identi.ca/twitter blog : Android Montreal, le 01/09/2010.
Threads and Services. Background Processes One of the key differences between Android and iPhone is the ability to run things in the background on Android.
HTTP and Threads. Getting Data from the Web Believe it or not, Android apps are able to pull data from the web. Developers can download bitmaps and text.
Serialization. Serialization is the process of converting an object into an intermediate format that can be stored (e.g. in a file or transmitted across.
Apps Find the latest version of this document at
Continue with behavioral marketing. Tweets. Reports. Homework: capture tweets project.
Working in the Background Radan Ganchev Astea Solutions.
Introduction to Socket Programming in Android Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
User Interface Android GUI Tool OpenGL API XML Writer Optimized Layout Algorithm WPF Component Inter.
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.
Adding Location Nasrullah. Adding Location Adding a Map Activity Obtaining a Map API Debug Key Adding a Map View Finding an Address with Google’s GeoCoder.
Server - Client Communication Getting data from server.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
learn. do. dream. Going Native Native Application Integration Attachments Camera GPS Mail Maps Phone Voice Input.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
네트워크 전송 1/2 UNIT 29 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Android Network 통신 2.
Apps Find the latest version of this document at
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
 Tracks seats availability in a specific class (CRN)- only for HOKIES.  Has the ability to track a list of classes.  The tracking list grows dynamically.
David Sutton MOBILE INTERNET. OUTLINE  This week’s app – an RSS feed reader  Mobile internet considerations  Threads (recap)  RSS feeds  Using AsyncTask.
GEOVISUALIZATION: VISUALIZE THAT ON A MAP Sarah G. Park April 14, 2016.
Developing for Chromecast Cast Companion Library & Custom Receiver Application.
Lecture 5: Location Topics: Google Play Services, Location API Date: Feb 16, 2016.
Using Retrofit framework in implementation of Android REST client David Ante Macan*, Zlatko Stapić, Milan Pavlović* University of Zagreb Faculty of Organization.
Esri UC 2014 | Technical Workshop | Administering ArcGIS for Server with Python Jon Bodamer.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
Messaging and Networking. Objectives Send SMS messages using the Messaging app Send SMS messages programmatically from within your app Receive and consume.
Multithreading Chapter 6. Objectives Understand the benefits of multithreading on Android Understand multi-threading fundamentals Know the Thread class.
H W #9 Clues CSCI 571 Spring, H W# 9 P rototype YouTube Link :
Mobility Assistant for Visually Impaired (MAVI) ANDROID APP
Small talk with the UI thread
Cosc 5/4730 REST services.
HUJI Post PC Workshop 1 Introduction to Android Development Ari Sprung
Student Introduction.
Brandon Dean, Elliot Garner, Brannon Mason
CS371m - Mobile Computing Responsiveness.
CS323 Android Topics Network Basics for an Android App
Mobile Computing With Android ACST 4550 Android Database Storage
Android Topics Asynchronous Callsbacks
Android Topics Threads and the MessageQueue
Android Developer Fundamentals V2
Android Developer Fundamentals V2
Threads, Handlers, and AsyncTasks
// Please Setting App_name to Send Successful
Android Threads Dimitar Ivanov Mobile Applications with Android
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

HUJI Post PC Workshop 5 Files, Threading, and Web Services Sasha Goldshtein

Working with Files Android apps can read and write files from their local directory ◦ /data/data/il.ac.huji.myapp/files Standard Java I/O API List students =...; FileOutputStream out = openFileOutput( “students”, MODE_PRIVATE); ObjectOutputStream objOut = new ObjectOutputStream(out); objOut.writeObject(students); objOut.close(); out.close(); List students =...; FileOutputStream out = openFileOutput( “students”, MODE_PRIVATE); ObjectOutputStream objOut = new ObjectOutputStream(out); objOut.writeObject(students); objOut.close(); out.close();

Demonstration: Files and DDMS DDMS can show you the device’s file system, download and upload files

Working with Threads Offload any considerable work to a background thread Thread t = new Thread( new Runnable() { public void run() {... } ); t.start(); Thread t = new Thread( new Runnable() { public void run() {... } ); t.start();

Demonstration: AsyncTask Helper for doing work in the background and posting progress + results public class LineCount extends AsyncTask { protected void onPreExecute() { //Initialize progress dialog } protected Long doInBackground(String... files) { //Process files and call publishProgress periodically } protected void onProgressUpdate(Integer... progress) { //Update progress dialog to progress[0] } protected void onPostExecute(Long result) { //Dismiss progress dialog and display result } public class LineCount extends AsyncTask { protected void onPreExecute() { //Initialize progress dialog } protected Long doInBackground(String... files) { //Process files and call publishProgress periodically } protected void onProgressUpdate(Integer... progress) { //Update progress dialog to progress[0] } protected void onPostExecute(Long result) { //Dismiss progress dialog and display result } new LineCount().execute(“file1”, “file2”, “file3”);

Accessing Web Services The world is at your fingertips with HTTP and JSON ◦ HTTP requests with HttpURLConnection ◦ Parse JSON with JSONObject {..., “results”: [ { “from_user”: “igoogledisrael”, “text”: “Beer in the Hebrew University”,... },... ] } {..., “results”: [ { “from_user”: “igoogledisrael”, “text”: “Beer in the Hebrew University”,... },... ] }

Demonstration: Accessing Web Services Google Geocoding API URL url = new URL(“ + “geocode/json?address=Jerusalem&sensor=false”); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); InputStream in = new BufferedInputStream(conn.getInputStream()); String response = readStream(in); //Omitted for brevity JSONObject json = new JSONObject(response); JSONArray arr = json.getJSONArray(“results”); JSONObject res = arr.getJSONObject(0); JSONObject geo = res.getJSONObject(“geometry”); JSONObject loc = geo.getJSONObject(“location”); double latitude = loc.getDouble(“lat”); double longitude = loc.getDouble(“lon”); URL url = new URL(“ + “geocode/json?address=Jerusalem&sensor=false”); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); InputStream in = new BufferedInputStream(conn.getInputStream()); String response = readStream(in); //Omitted for brevity JSONObject json = new JSONObject(response); JSONArray arr = json.getJSONArray(“results”); JSONObject res = arr.getJSONObject(0); JSONObject geo = res.getJSONObject(“geometry”); JSONObject loc = geo.getJSONObject(“location”); double latitude = loc.getDouble(“lat”); double longitude = loc.getDouble(“lon”); { “results”: [ { “geometry”: { “location”: { “lat”: 30.0, “lon”: 24.0 } },... ],... } { “results”: [ { “geometry”: { “location”: { “lat”: 30.0, “lon”: 24.0 } },... ],... }

Homework 5 Todo List App v4 ◦ Repo tag: v4 On start, search for tweets tagged #todoapp and create new tasks Add a todo thumbnail ◦ Retrieved from Flickr API by search keyword 12:38 Buy flowers 20/01/2013 Invite David 26/04/2013 Call Mom 29/04/2013 Delete Item Add Thumbnail Buy flowers Add Thumbnail OKCancel dinner Dialog

Additional Resources java.io summary.html Processes and Threads threads.html AsyncTask HttpURLConnection on.html