Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS323 Android Topics Network Basics for an Android App

Similar presentations


Presentation on theme: "CS323 Android Topics Network Basics for an Android App"— Presentation transcript:

1 CS323 Android Topics Network Basics for an Android App
HTTP Requests and Responses Android Networking Tasks Access Permissions Build a simple App to test concepts

2 Android Networking - Concept
Data is requested that is hosted on a web server. How does it get from the web server to your application? This involves a couple of things: Android access permissions HTTP requests Background thread, to make the network process efficient.

3 Basics of Android Networking
A networked Android App consists of a client, a web server, and a network. A server holds data files that we wish to access. The Android device is a client. Server data is accessed through an HTTP request. A client requests data through the HTTP request and the server response with a return of the data.

4 HTTP Request and Response Tasks
To access data located on a server, an app must build a request for the data and send it to the server. An HyperText Transfer Protocol (HTTP) request is built. The requested file or data is specified. When the server receives the HTTP request, it retrieves the requested file and returns it as part of the HTTP response.

5 Host/domain/authority
HTTP request example: Query: Often times, an http data request will include the URL and a data query. Host/domain/authority Protocol/scheme Resource path

6 Networking Steps for Android
Step 1: Using a background thread, create and send a HTTP request to the server. Include all necessary request information. NOTE: An http request is sent specifically to a URL. Step 2: Once the server replies, receive the response and parse it into something an Android app will understand. Step 3: Using the main thread, update the UI to show the results from the HTTP request.

7 User Permissions Question and Answers

8 User Permissions Question:
Does an Android app automatically have access to the Internet?

9 User Permissions Answer:
By default, an Android app does NOT have access to the Internet.

10 User Permissions Question:
What happens if you do not provide appropriate permissions?

11 User Permissions Answer:
If a necessary system permission is not granted, the app may not operate correctly.

12 User Permissions Question: Where do you declare app permissions?

13 User Permissions Answer:
App permissions are declared in the Android Manifest file.

14 User Permission Examples:
A permission is defined by an app with a  permission element. Example 1: "android.permission.CAMERA"  Example 2: "android.permission.READ_CONTACTS” Example 3: "android.permission.INTERNET" Example 4: "android.permission.ACCESS_NETWORK_STATE"

15 Network Permissions The manifest must include the following permissions: <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

16 Explore Useful Permissions

17

18 Build the App from Lab 8 Exercise 1
Build the App from Lab 8 Exercise 1. Click the button to retrieve an image from a server and display it in an ImageView.


Download ppt "CS323 Android Topics Network Basics for an Android App"

Similar presentations


Ads by Google