10/27/17. Network Connec1on. Outline. Connect to the Internet. Connect to the Internet. Perform Network Operations. Perform Network Operations

Size: px
Start display at page:

Download "10/27/17. Network Connec1on. Outline. Connect to the Internet. Connect to the Internet. Perform Network Operations. Perform Network Operations"

Transcription

1 Connecting to the Internet Outline Network Connec1on CS443 Mobile Applica1ons Instructor: Bo Sheng Perform network operations Manage network usage Parsing data 1 2 Connect to the Internet Permissions in the manifest file <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> Create an HTTP client Common approach for Android apps to send and receive data HttpURLConnection client: support HTTPS, streaming data, configurable timeouts, IPV6, Connect to the Internet Check the network connection Before your app attempts to connect to the network Using getactivenetworkinfo() and isconnected() getsystemservice(context.connectivity_service); NetworkInfo networkinfo = connmgr.getactivenetworkinfo(); if (networkinfo!= null && networkinfo.isconnected()) { // fetch data else { // display error URL url = new URL(" HttpURLConnection urlconnection = (HttpURLConnection) url.openconnection(); 3 4 Start a separate thread Network operations can involve unpredictable delays E.g., using AsyncTask doinbackground : network connection and operation onpostexecute : update the UI 1. The app passes the specified URL to the AsyncTask. 2. The AsyncTask method doinbackground() calls the downloadurl() method. 3. The downloadurl() method takes a URL string as a parameter and uses it to create a URL object. 4. The URL object is used to establish an HttpURLConnection. 5. The HttpURLConnection object fetches the web page content as an InputStream. 6. The InputStream is passed to the readit() method, which converts the stream to a string. 7. Finally, the AsyncTask's onpostexecute() method displays the string in the main activity's UI. Obtain a new HttpURLConnection by calling URL.openConnection() Prepare the request: set up the parameters of the HttpURLConnection, e.g., Timeout parameters conn.setreadtimeout(10000 /* milliseconds */); conn.setconnecttimeout(15000 /* milliseconds */); Request method: GET, POST, PUT, 5 6 1

2 Connection is initiated when HttpURLConnection.connect() is called Apps are not always required to explicitly call connect method Some operations such as getinputstream will implicitly perform the connection when necessary. Response header from the server: content type/length, encoding conn.connect(); int response = conn.getresponsecode(); Log.d(DEBUG_TAG, "The response is: " + response); An int representing the three digit HTTP Status-Code:1xx: Informational, 2xx: Success, 3xx: Redirection, 4xx: Client Error, 5xx: Server Error Response body from the server: handled by regular input stream with getinputstream() InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readstream(in); Disconnect: Once the response body has been read, the HttpURLConnection should be closed by calling disconnect(). Disconnecting releases the resources held by a connection so they may be closed or reused. 7 8 URL url = new URL(" HttpURLConnection conn = (HttpURLConnection) url.openconnection(); getsystemservice(context.connectivity_service); NetworkInfo networkinfo = connmgr.getactivenetworkinfo(); if (networkinfo!= null && networkinfo.isconnected()) { conn.setreadtimeout(10000 /* milliseconds */); conn.setconnecttimeout(15000 /* milliseconds */); conn.connect(); InputStream in = new BufferedInputStream(conn.getInputStream()); readstream(in); else { // display error Post content: upload data to a web server Configure the connection for output using setdooutput(true) Call either setfixedlengthstreamingmode(int) when the body length is known in advance, or setchunkedstreamingmode(int) when it is not. urlconnection.setdooutput(true); urlconnection.setchunkedstreamingmode(0); OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream()); writestream(out); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readstream(in); 9 10 HW2 Convert the InputStream to a target data type InputStream is = urlconnection.getinputstream(); Bitmap bitmap = BitmapFactory.decodeStream(is); Reader reader = new InputStreamReader(is, "UTF-8"); char[] buffer = new char[len]; reader.read(buffer); return new String(buffer); Thread 1 Start from the beginning While(true){... sleep(3000); if(count<4){ randomly pick a tile to place X ; count++; updateui; Ac1vity Int count=0; GridView Array={, X,, O, Start onclick Thread 2 While(cur!=dest){... move to the next tile; updateui(); if passed a X { clear the tile; count--; pause;

3 Fine-grained control of network resources User specific settings, such as How often your app syncs data? Perform network operations only when on WiFi? Transfer data while roaming? Types of network connection (WiFi or cellular) Check the network state before performing network operations ConnectivityManager: Answers queries about the state of network connectivity. Notify applications when network connectivity changes Monitor network connections (Wi-Fi, GPRS, UMTS, etc.) Send broadcast intents when network connectivity changes Attempt to "fail over" to another network when connectivity to a network is lost Provide an API that allows applications to query the coarse-grained or fine-grained state of the available networks Provide an API that allows applications to request and select networks for their data traffic ConnectivityManager: Answers queries about the state of network connectivity. Notify applications when network connectivity changes NetworkInfo: Describes the status of a network interface of a given type (currently either Mobile or Wi-Fi) getsystemservice(context.connectivity_service); NetworkInfo networkinfo = connmgr.getnetworkinfo(connectivitymanager.type_wifi); boolean iswificonn = networkinfo.isconnected(); networkinfo = connmgr.getnetworkinfo(connectivitymanager.type_mobile); boolean ismobileconn = networkinfo.isconnected(); Log.d(DEBUG_TAG, "Wifi connected: " + iswificonn); Log.d(DEBUG_TAG, "Mobile connected: " + ismobileconn); ConnectivityManager: Answers queries about the state of network connectivity. Notify applications when network connectivity changes NetworkInfo: Describes the status of a network interface of a given type (currently either Mobile or Wi-Fi) isavailable() and isconnected() : Always check isconnected() before performing network operations, since it handles cases like flaky mobile networks, airplane mode, and restricted background data getactivenetworkinfo(): returns a NetworkInfo instance representing the first connected network interface it can find, or null if none of the interfaces is connected public boolean isonline() { getsystemservice(context.connectivity_service); NetworkInfo networkinfo = connmgr.getactivenetworkinfo(); return (networkinfo!= null && networkinfo.isconnected()); For example: allow users to upload videos only when the device is connected to a Wi-Fi network; sync (or not) depending on specific criteria such as network availability, time interval, Required permissions android.permission.internet Allows applications to open network socket android.permission.access_network_state Allows applications to access information about networks

4 10/27/17 MANAGE_NETWORK_USAGE Intent Filter: shows settings for managing the network data usage of a specific application. If you app includes an activity that offers options to control data usage <activity android:label="settingsactivity" android:name=".settingsactivity"> <intent-filter> <action android:name="android.intent.action.manage_network_usage" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> Settings A Preference object represents a single setting Key-value pairs are stored in a default SharedPreferences file PreferenceActivity or PreferenceFragment Different types of preferences CheckBoxPreference ListPreference EditTextPreference Define Preferences in XML Implement a preferences activity A subclass of PreferenceActivity Implement public void onsharedpreferencechanged( ){ // Sets refreshdisplay to true so that when the user returns to the main // activity, the display refreshes to reflect the new settings. NetworkActivity.refreshDisplay = true; Respond to preference changes Fetch the preferences settings in public void onstart () { super.onstart(); SharedPreferences sharedprefs = PreferenceManager.getDefaultSharedPreferences(this); spref = sharedprefs.getstring("listpref", "Wi-Fi"); updateconnectedflags(); if(refreshdisplay){ loadpage(); Respond to preference changes Get the current network state public void updateconnectedflags() { getsystemservice(context.connectivity_service); NetworkInfo activeinfo = connmgr.getactivenetworkinfo(); if (activeinfo!= null && activeinfo.isconnected()) { wificonnected = activeinfo.gettype() == ConnectivityManager.TYPE_WIFI; mobileconnected = activeinfo.gettype() == ConnectivityManager.TYPE_MOBILE; else { wificonnected = false; mobileconnected = false; Respond to preference changes Check the network preference public void loadpage() { if (((spref.equals(any)) && (wificonnected mobileconnected)) ((spref.equals(wifi)) && (wificonnected))) { // AsyncTask subclass new DownloadXmlTask().execute(URL); else { showerrorpage();

5 Choose a parser (XmlPullParser) via Xml.newPullParser() Analyze the feed <entry> <id> <re:rank scheme=" <title type="text">where is my data file?</title> <category scheme=" term="android"/> <category scheme=" term="file"/> <author> <name>cliff2310</name> <uri> </author> <link rel="alternate" href=" /> <published> t00:30:54z</published> <updated> t00:30:54z</updated> <summary type="html"> <p>i have an Application that requires a data file...</p> </summary> </entry> Instantiate the parser via Xml.newPullParser() Data fed by an InputStream Start parsing with nexttag() public List parse(inputstream in) throws XmlPullParserException, IOException { try { XmlPullParser parser = Xml.newPullParser(); parser.setfeature(xmlpullparser.feature_process_namespaces, false); parser.setinput(in, null); parser.nexttag(); return readfeed(parser); finally { in.close(); Read the feed Look for elements tagged entry Return a List containing the entries private List readfeed(xmlpullparser parser) throws XmlPullParserException, IOException { List entries = new ArrayList(); parser.require(xmlpullparser.start_tag, ns, "feed"); while (parser.next()!= XmlPullParser.END_TAG) { if (parser.geteventtype()!= XmlPullParser.START_TAG) { continue; String name = parser.getname(); if (name.equals("entry")) { entries.add(readentry(parser)); else { skip(parser); return entries; Parse each entry A "read" method for each tag you're interested in. For example, readentry(), readtitle(), and so on. private Entry readentry(xmlpullparser parser) throws XmlPullParserException, IOException { parser.require(xmlpullparser.start_tag, ns, "entry"); String title = null; String summary = null; String link = null; while (parser.next()!= XmlPullParser.END_TAG) { if (parser.geteventtype()!= XmlPullParser.START_TAG) { continue; String name = parser.getname(); if (name.equals("title")) { title = readtitle(parser); else if (name.equals("summary")) { summary = readsummary(parser); else if (name.equals("link")) { link = readlink(parser); else { skip(parser); return new Entry(title, summary, link); Read a user input (city s name or zip code) 2. Display the temperature 3. Display the weather icon openweathermap.org References Query examples q=boston,ma&appid=f9a0da d1453d0faa23006c2d9 4. Show the map of the city zip=02125,us&appid=f9a0da d1453d0faa23006c2d

6 Main steps Get the user input and form the http URL Then, download the data from the server Analyze/parse the returned data Temperature Icon file name Latitude, longitude Download the icon file Parse JSON data {"coord":{"lon":-71.06,"lat":42.36, "weather":[{"id":800,"main":"clear","descrip1on":"sky is clear","icon":"01d"], "base":"sta1ons", "main":{"temp":294.73,"pressure":1008,"humidity":60,"temp_min": ,"temp_max":297.15, "visibility":16093,"wind":{"speed":4.1,"deg":250,"clouds":{"all":1,"dt": ,"sys":{"type":1,"id":1801,"message": ,"country":"US","sunrise": ,"sunset": ,"id": ,"name":"Boston","cod":200 JSONObject jobj=new JSONObject(stringInput); jobj.getstring( base ), jobj.getjsonobject( coord ); Settings Use preference fragments public static class SettingsFragment extends PreferenceFragment public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate);... // Load the preferences from an XML resource addpreferencesfromresource(r.xml.preferences); public class SettingsActivity extends Activity protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Display the fragment as the main content. getfragmentmanager().begintransaction().replace(android.r.id.content, new SettingsFragment()).commit(); 33 6

Software Engineering Large Practical: Accessing remote data and XML parsing. Stephen Gilmore School of Informatics October 8, 2017

Software Engineering Large Practical: Accessing remote data and XML parsing. Stephen Gilmore School of Informatics October 8, 2017 Software Engineering Large Practical: Accessing remote data and XML parsing Stephen Gilmore School of Informatics October 8, 2017 Contents 1. Android system permissions 2. Getting a network connection

More information

Communicating with a Server

Communicating with a Server Communicating with a Server Client and Server Most mobile applications are no longer stand-alone Many of them now have a Cloud backend The Cloud Client-server communication Server Backend Database HTTP

More information

Mobile Development Lecture 9: Android & RESTFUL Services

Mobile Development Lecture 9: Android & RESTFUL Services Mobile Development Lecture 9: Android & RESTFUL Services Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com What is a RESTFUL Web Service REST stands for REpresentational State Transfer. In

More information

IEMS 5722 Mobile Network Programming and Distributed Server Architecture

IEMS 5722 Mobile Network Programming and Distributed Server Architecture Department of Information Engineering, CUHK MScIE 2 nd Semester, 2016/17 IEMS 5722 Mobile Network Programming and Distributed Server Architecture Lecture 4 HTTP Networking in Android Lecturer: Albert C.

More information

32. And this is an example on how to retrieve the messages received through NFC.

32. And this is an example on how to retrieve the messages received through NFC. 4. In Android applications the User Interface (UI) thread is the main thread. This thread is very important because it is responsible with displaying/drawing and updating UI elements and handling/dispatching

More information

OFFLINE MODE OF ANDROID

OFFLINE MODE OF ANDROID OFFLINE MODE OF ANDROID APPS @Ajit5ingh ABOUT ME new Presenter( Ajit Singh, github.com/ajitsing, www.singhajit.com, @Ajit5ingh ) AGENDA Why offline mode? What it takes to build an offline mode Architecture

More information

Android Connectivity & Google APIs

Android Connectivity & Google APIs Android Connectivity & Google APIs Lecture 5 Operating Systems Practical 2 November 2016 This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license,

More information

Mobile Application Development MyRent Settings

Mobile Application Development MyRent Settings Mobile Application Development MyRent Settings Waterford Institute of Technology October 13, 2016 John Fitzgerald Waterford Institute of Technology, Mobile Application Development MyRent Settings 1/19

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

Mobile and Ubiquitous Computing: Android Programming (part 4)

Mobile and Ubiquitous Computing: Android Programming (part 4) Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,

More information

Spring Lecture 5 Lecturer: Omid Jafarinezhad

Spring Lecture 5 Lecturer: Omid Jafarinezhad Mobile Programming Sharif University of Technology Spring 2016 - Lecture 5 Lecturer: Omid Jafarinezhad Storage Options Android provides several options for you to save persistent application data. The

More information

Distributed Systems 2011 Assignment 1

Distributed Systems 2011 Assignment 1 Distributed Systems 2011 Assignment 1 Gábor Sörös gabor.soros@inf.ethz.ch The Exercise Objectives Get familiar with Android programming Emulator, debugging, deployment Learn to use UI elements and to design

More information

Analyzing Wi Fi P2P in the context of a hangman game 1

Analyzing Wi Fi P2P in the context of a hangman game 1 Analyzing Wi Fi P2P in the context of a hangman game 1 1. Introduction and Findings 2 3 Wi Fi P2P, which complies with the Wi Fi Alliance's Wi Fi Direct certification program, is a relatively new addition

More information

COMP4521 EMBEDDED SYSTEMS SOFTWARE

COMP4521 EMBEDDED SYSTEMS SOFTWARE COMP4521 EMBEDDED SYSTEMS SOFTWARE LAB 5: USING WEBVIEW AND USING THE NETWORK INTRODUCTION In this lab we modify the application we created in the first three labs. Instead of using the default browser,

More information

CS 403X Mobile and Ubiquitous Computing Lecture 5: Web Services, Broadcast Receivers, Tracking Location, SQLite Databases Emmanuel Agu

CS 403X Mobile and Ubiquitous Computing Lecture 5: Web Services, Broadcast Receivers, Tracking Location, SQLite Databases Emmanuel Agu CS 403X Mobile and Ubiquitous Computing Lecture 5: Web Services, Broadcast Receivers, Tracking Location, SQLite Databases Emmanuel Agu Web Services What are Web Services? Means to call a remote method

More information

Distributed Systems Assignment 1

Distributed Systems Assignment 1 Distributed Systems Assignment 1 Marian.george@inf.ethz.ch Distributed Systems Assignment 1 1 The Exercise Objectives Get familiar with Android programming Emulator, debugging, deployment Learn to use

More information

Assignment 2. Start: 15 October 2010 End: 29 October 2010 VSWOT. Server. Spot1 Spot2 Spot3 Spot4. WS-* Spots

Assignment 2. Start: 15 October 2010 End: 29 October 2010 VSWOT. Server. Spot1 Spot2 Spot3 Spot4. WS-* Spots Assignment 2 Start: 15 October 2010 End: 29 October 2010 In this assignment you will learn to develop distributed Web applications, called Web Services 1, using two different paradigms: REST and WS-*.

More information

South Africa

South Africa South Africa 2013 Lecture 8: Accessing the Web andunittests http://aiti.mit.edu Interacting with the Web How to Access Web Content 1. Give your app permission to access the web 2. Open a connection to

More information

An Overview of the Android Programming

An Overview of the Android Programming ID2212 Network Programming with Java Lecture 14 An Overview of the Android Programming Hooman Peiro Sajjad KTH/ICT/SCS HT 2016 References http://developer.android.com/training/index.html Developing Android

More information

Answers to Exercises

Answers to Exercises Answers to Exercises CHAPTER 1 ANSWERS 1. What is an AVD? Ans: An AVD is an Android Virtual Device. It represents an Android emulator, which emulates a particular configuration of an actual Android device.

More information

Distributed Systems Assignment 1

Distributed Systems Assignment 1 Distributed Systems Assignment 1 marian.george@inf.ethz.ch Distributed Systems Assignment 1 1 The Exercise Objectives Get familiar with Android programming Emulator, debugging, deployment Learn to use

More information

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection)

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in

More information

The Suggest Example layout (cont ed)

The Suggest Example layout (cont ed) Using Web Services 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 7: Working with Web Services Android provides a full set of Java-standard networking APIs, such as the java.net package containing among

More information

C24: Web API: Passing Arguments and Parsing Returns

C24: Web API: Passing Arguments and Parsing Returns CISC 3120 C24: Web API: Passing Arguments and Parsing Returns Hui Chen Department of Computer & Information Science CUNY Brooklyn College 5/7/2018 CUNY Brooklyn College 1 Outline Parsing arguments/data

More information

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket Objectives TCP connections To understand programming of clients that connect to servers via TCP To understand the basics of programming of servers that accept TCP connections To practice programming of

More information

Computer Science Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 26, 2017

Computer Science Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 26, 2017 Computer Science Large Practical: Storage, Settings and Layouts Stephen Gilmore School of Informatics October 26, 2017 Contents 1. Storing information 2. Kotlin compilation 3. Settings 4. Layouts 1 Storing

More information

Android/Java Lightning Tutorial JULY 30, 2018

Android/Java Lightning Tutorial JULY 30, 2018 Android/Java Lightning Tutorial JULY 30, 2018 Java Android uses java as primary language Resource : https://github.mit.edu/6178-2017/lec1 Online Tutorial : https://docs.oracle.com/javase/tutorial/java/nutsandbolts/inde

More information

Chapter 15. XML Parsing JSON Parsing Connectivity Status HTTP Client Web Services

Chapter 15. XML Parsing JSON Parsing Connectivity Status HTTP Client Web Services XML Parsing JSON Parsing Connectivity Status HTTP Client Web Services XML Extensible Markup Language (XML) is a set of rules for encoding documents in a readable form. Similar to HTML but

More information

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

The Internet. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046 The Internet CS 2046 Mobile Application Development Fall 2010 Announcements HW2 due Monday, 11/8, at 11:59pm If you want to know what it means to root your phone, or what this does, see Newsgroup HW1 grades

More information

CS193j, Stanford Handout #26. Files and Streams

CS193j, Stanford Handout #26. Files and Streams CS193j, Stanford Handout #26 Summer, 2003 Manu Kumar Files and Streams File The File class represents a file or directory in the file system. It provides platform independent ways to test file attributes,

More information

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism

1. Implementation of Inheritance with objects, methods. 2. Implementing Interface in a simple java class. 3. To create java class with polymorphism ANDROID TRAINING COURSE CONTENT SECTION 1 : INTRODUCTION Android What it is? History of Android Importance of Java language for Android Apps Other mobile OS-es Android Versions & different development

More information

SAVING SIMPLE APPLICATION DATA

SAVING SIMPLE APPLICATION DATA 1 DATA PERSISTENCE OBJECTIVES In this chapter, you will learn how to persist data in your Android applications. Persisting data is an important topic in application development, as users typically expect

More information

Starting Another Activity Preferences

Starting Another Activity Preferences Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the

More information

Coding for Life--Battery Life, That Is

Coding for Life--Battery Life, That Is Coding for Life--Battery Life, That Is Jeff Sharkey May 27, 2009 Post your questions for this talk on Google Moderator: code.google.com/events/io/questions Why does this matter? Phones primarily run on

More information

App Development for Smart Devices. Lec #17: Networking II

App Development for Smart Devices. Lec #17: Networking II App Development for Smart Devices CS 495/595 - Fall 2011 Lec #17: Networking II Tamer Nadeem Dept. of Computer Science Objective Bluetooth Network Connectivity and WiFi Presentation - Mobile Crowdsensing:

More information

Android Basics Nanodegree Syllabus

Android Basics Nanodegree Syllabus Android Basics Nanodegree Syllabus Before You Start This is an entry-level, single term Nanodegree program with no prior programming experience required. Support Options We are here to support you every

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL II) Lecture 6: Notification and Web Services Notification A notification is a user interface element that you display outside your app's normal

More information

UNDERSTANDING ACTIVITIES

UNDERSTANDING ACTIVITIES Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device

More information

Presented by: Megan Bishop & Courtney Valentine

Presented by: Megan Bishop & Courtney Valentine Presented by: Megan Bishop & Courtney Valentine Early navigators relied on landmarks, major constellations, and the sun s position in the sky to determine latitude and longitude Now we have location- based

More information

Software Engineering Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 27, 2017

Software Engineering Large Practical: Storage, Settings and Layouts. Stephen Gilmore School of Informatics October 27, 2017 Software Engineering Large Practical: Storage, Settings and Layouts Stephen Gilmore School of Informatics October 27, 2017 Contents 1. Storing information 2. Settings 3. Layouts 1 Storing information Storage

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not

More information

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Socket 101 Excerpt from Network Programming

Socket 101 Excerpt from Network Programming Socket 101 Excerpt from Network Programming EDA095 Nätverksprogrammering Originals by Roger Henriksson Computer Science Lund University Java I/O Streams Stream (swe. Ström) - A stream is a sequential ordering

More information

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment PA4: Multi-thread File Downloader Page 1 Assignment What to Submit Write a program that downloads a file from the Internet using multiple threads. The application has a Graphical Interface written in JavaFX,

More information

Android File & Storage

Android File & Storage Files Lecture 9 Android File & Storage Android can read/write files from two locations: Internal (built into the device) and external (an SD card or other drive attached to device) storage Both are persistent

More information

Android Basics Nanodegree Syllabus

Android Basics Nanodegree Syllabus Android Basics Nanodegree Syllabus Before You Start This is an entry-level program. No prior programming experience required. Project 1: Build a Single Screen App Design and implement a single screen app

More information

Reading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.

Reading from URL. Intent - open URL  get an input stream on the connection, and read from the input stream. Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)

More information

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations

Writing Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations Writing Efficient Drive Apps for Android Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations Raise your hand if you use Google Drive source: "put your hands up!" (CC-BY) Raise the other

More information

External Services. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion

External Services. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion External Services CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion 1 External Services Viewing websites Location- and map-based functionality

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

More information

Android Networking and Connec1vity

Android Networking and Connec1vity Android Networking and Connec1vity Android and Networking Smartphones in general and Android in par1cular provide several means of being connected Telephony connec1ons for voice communica1on, the primary

More information

Overview of Activities

Overview of Activities d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming

More information

Google Maps Troubleshooting

Google Maps Troubleshooting Google Maps Troubleshooting Before you go through the troubleshooting guide below, make sure that you ve consulted the class FAQ, Google s Map Activity Tutorial, as well as these helpful resources from

More information

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Revision history 90001431-13 Revision Date Description A October 2014 Original release. B October 2017 Rebranded the document. Edited the document.

More information

Services. service: A background task used by an app.

Services. service: A background task used by an app. CS 193A Services This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Services service: A background task

More information

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. 1 Thread A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main

More information

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good

More information

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26

Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26 Upcoming Assignments Quiz Friday? Lab 5 due today Alpha Version due Friday, February 26 Inject one subtle defect (fault seeding) To be reviewed by a few class members Usability study by CPE 484 students

More information

THE CONTEXTUAL DATA SUPPLIER. API Integration Guide

THE CONTEXTUAL DATA SUPPLIER. API Integration Guide THE CONTEXTUAL DATA SUPPLIER API Integration Guide Contextual Data API v3 April 2018 Overview No Matter if you want to integrate our Contextual Data API into your website with JavaScript or call it from

More information

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs

More information

Android Application Model I

Android Application Model I Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);

More information

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

More information

Login with Amazon. Getting Started Guide for Android apps

Login with Amazon. Getting Started Guide for Android apps Login with Amazon Getting Started Guide for Android apps Login with Amazon: Getting Started Guide for Android Copyright 2017 Amazon.com, Inc., or its affiliates. All rights reserved. Amazon and the Amazon

More information

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities

Activities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Activities https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Overview What is an Activity Starting and stopping activities The Back Stack

More information

サーブレットと Android との連携. Generated by Foxit PDF Creator Foxit Software For evaluation only.

サーブレットと Android との連携. Generated by Foxit PDF Creator Foxit Software   For evaluation only. サーブレットと Android との連携 Android からサーブレットへの GET リクエスト Android からサーブレットにリクエストを出すには スレッドを使わなければなりません 枠組みは以下のようになります Android 側 * Hello JSON package jp.ac.neec.kmt.is04.takata; import の記述 public class HelloJsonActivity

More information

SharedPreferences Internal Storage External Storage SQLite databases

SharedPreferences Internal Storage External Storage SQLite databases SharedPreferences Internal Storage External Storage SQLite databases Use when you want to store small amounts of primitive data A persistent map that holds key-value pairs of simple data types Automatically

More information

CS371m - Mobile Computing. Responsiveness

CS371m - Mobile Computing. Responsiveness CS371m - Mobile Computing Responsiveness An App Idea From Nifty Assignments Draw a picture use randomness Pick an equation at random Operators in the equation have the following property: Given an input

More information

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities

More information

Topics Covered in the Android Apps Development Training

Topics Covered in the Android Apps Development Training Topics Covered in the Android Apps Development Training 1. Android Architecture sdk, jdk, class files,.dex, installation, sdk manager, avd manager, avd configurations, emulator, Android Framework Versions,

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving into Android. By Jeroen Tietema. Jeroen Tietema, Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com

More information

register/unregister for Intent to be activated if device is within a specific distance of of given lat/long

register/unregister for Intent to be activated if device is within a specific distance of of given lat/long stolen from: http://developer.android.com/guide/topics/sensors/index.html Locations and Maps Build using android.location package and google maps libraries Main component to talk to is LocationManager

More information

Accessing Cellular Network Efficiently Without the Battery Drain. Lee, Chang Hwan, SK Telecom lipisoft at gmail dot com Kandroid: Lipi(리피)

Accessing Cellular Network Efficiently Without the Battery Drain. Lee, Chang Hwan, SK Telecom lipisoft at gmail dot com Kandroid: Lipi(리피) Accessing Cellular Network Efficiently Without the Battery Drain Lee, Chang Hwan, SK Telecom lipisoft at gmail dot com Kandroid: Lipi(리피) Contents Wired vs Cellular Cellular Network LTE Protocol Stack

More information

Android" Application Development SAMS. Sams Teach Yourself. Shane Conder. Lauren Darcey. Second Edition

Android Application Development SAMS. Sams Teach Yourself. Shane Conder. Lauren Darcey. Second Edition Lauren Darcey Shane Conder Sams Teach Yourself Android" Application Development Second Edition SAMS 800 East 96th Street, Indianapolis, Indiana, 46240 USA Table of Contents Introduction 1 Who Should Read

More information

ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS

ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS ANDROID SERVICES, BROADCAST RECEIVER, APPLICATION RESOURCES AND PROCESS 1 Instructor: Mazhar Hussain Services A Service is an application component that can perform long-running operations in the background

More information

The Basis of Data. Steven R. Bagley

The Basis of Data. Steven R. Bagley The Basis of Data Steven R. Bagley So far How to create a UI View defined in XML Java-based Activity as the Controller Services Long running processes Intents used to send messages between things asynchronously

More information

Tabel mysql. Kode di PHP. Config.php. Service.php

Tabel mysql. Kode di PHP. Config.php. Service.php Tabel mysql Kode di PHP Config.php Service.php Layout Kode di Main Activity package com.example.mini.webandroid; import android.app.progressdialog; import android.os.asynctask; import android.support.v7.app.appcompatactivity;

More information

Course Learning Outcomes (CLO): Student Outcomes (SO):

Course Learning Outcomes (CLO): Student Outcomes (SO): Course Coverage Course Learning Outcomes (CLO): 1. Understand the technical limitations and challenges posed by current mobile devices and wireless communications; be able to evaluate and select appropriate

More information

Android Tutorial: Part 3

Android Tutorial: Part 3 Android Tutorial: Part 3 Adding Client TCP/IP software to the Rapid Prototype GUI Project 5.2 1 Step 1: Copying the TCP/IP Client Source Code Quit Android Studio Copy the entire Android Studio project

More information

Introduction to Android

Introduction to Android Introduction to Android http://myphonedeals.co.uk/blog/33-the-smartphone-os-complete-comparison-chart www.techradar.com/news/phone-and-communications/mobile-phones/ios7-vs-android-jelly-bean-vs-windows-phone-8-vs-bb10-1159893

More information

Upcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26

Upcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26 Upcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26 To be reviewed by a few class members Usability study by CPE 484 students

More information

Document Plan. Social Media Geolocation App. Robert McCaffrey, Matt Feld, Taylor Neal, David Kwon BLIPME

Document Plan. Social Media Geolocation App. Robert McCaffrey, Matt Feld, Taylor Neal, David Kwon BLIPME BLIPME Document Plan Social Media Geolocation App Robert McCaffrey, Matt Feld, Taylor Neal, David Kwon Blip is a social app aimed at combining new technology and design in a simple way to make going out

More information

LECTURE NOTES OF APPLICATION ACTIVITIES

LECTURE NOTES OF APPLICATION ACTIVITIES Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The

More information

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming

Lecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming University of Babylon College of Information Technology Department of Information Networks Mobile Fundamentals and Programming Lecture 7: Data Persistence : shared preferences Lecturer : Ali Kadhim Al-Bermani

More information

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015 Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional

More information

Java Training Center - Android Application Development

Java Training Center - Android Application Development Java Training Center - Android Application Development Android Syllabus and Course Content (3 months, 2 hour Daily) Introduction to Android Android and it's feature Android releases and Versions Introduction

More information

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/15/2014

More information

CS 351 Design of Large Programs Threads and Concurrency

CS 351 Design of Large Programs Threads and Concurrency CS 351 Design of Large Programs Threads and Concurrency Brooke Chenoweth University of New Mexico Spring 2018 Concurrency in Java Java has basic concurrency support built into the language. Also has high-level

More information

A Trip Planner for the Itract System Supporting Real-time Updates

A Trip Planner for the Itract System Supporting Real-time Updates A Trip Planner for the Itract System Supporting Real-time Updates Natalie Liden Faculty: Department of Mathematics and Computer Science Subject: Computer Science Points: 30hp Supervisor: Annika Klockar

More information

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27 Android Coding Dr. J.P.E. Hodgson August 23, 2010 Dr. J.P.E. Hodgson () Android Coding August 23, 2010 1 / 27 Outline Starting a Project 1 Starting a Project 2 Making Buttons Dr. J.P.E. Hodgson () Android

More information

J2ME crash course. Harald Holone

J2ME crash course. Harald Holone J2ME crash course Harald Holone 2006-01-24 Abstract This article gives a short, hands-on introduction to programming J2ME applications on the MIDP 2.0 platform. Basic concepts, such as configurations,

More information

App Development for Smart Devices. Lec #7: Windows Azure

App Development for Smart Devices. Lec #7: Windows Azure App Development for Smart Devices CS 495/595 - Fall 2011 Lec #7: Windows Azure Tamer Nadeem Dept. of Computer Science Objective Working in Background AsyncTask Cloud Computing Windows Azure Two Presentation

More information

... 1... 2... 2... 3... 3... 4... 4... 5... 5... 6... 6... 7... 8... 9... 10... 13... 14... 17 1 2 3 4 file.txt.exe file.txt file.jpg.exe file.mp3.exe 5 6 0x00 0xFF try { in.skip(9058); catch (IOException

More information

Loca%on Support in Android. COMP 355 (Muppala) Location Services and Maps 1

Loca%on Support in Android. COMP 355 (Muppala) Location Services and Maps 1 Loca%on Support in Android COMP 355 (Muppala) Location Services and Maps 1 Loca%on Services in Android Loca%on capabili%es for applica%ons supported through the classes in android.loca%on package and Google

More information

Writing a Protocol Handler

Writing a Protocol Handler Writing a Protocol Handler A URL object uses a protocol handler to establish a connection with a server and perform whatever protocol is necessary to retrieve data. For example, an HTTP protocol handler

More information

Android Help. Section 8. Eric Xiao

Android Help. Section 8. Eric Xiao Android Help Section 8 Eric Xiao The Midterm That happened Any residual questions? New Assignment! Make a low-fi prototype Must be interactive Use balsamiq or paper Test it with users 3 tasks Test task

More information

Android Programming (5 Days)

Android Programming (5 Days) www.peaklearningllc.com Android Programming (5 Days) Course Description Android is an open source platform for mobile computing. Applications are developed using familiar Java and Eclipse tools. This Android

More information

Midterm Examination. CSCE 4623 (Fall 2017) October 20, 2017

Midterm Examination. CSCE 4623 (Fall 2017) October 20, 2017 Midterm Examination CSCE 4623 (Fall 2017) Name: UA ID: October 20, 2017 Instructions: 1. You have 50 minutes to complete the exam. The exam is closed note and closed book. No material is allowed with you

More information

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each

More information