Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
Location-Based Services: Part 2 (Google Maps)
Manifest File, Intents, and Multiple Activities. Manifest File.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Cosc 4755 Blackberry and Android Embedding the browser in your app.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Android Development (Basics)
Data Storage: Part 1 (Preferences)
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
CS378 - Mobile Computing Web - WebView and Web Services.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Mobile Programming Lecture 6
DUE Hello World on the Android Platform.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
CS378 - Mobile Computing Web - WebView and Web Services.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
Android - Broadcast Receivers
User Interfaces: Part 1 (View Groups and Layouts).
Tutorial 5 Windows and Frames Section B - Working with Frames and Other Objects Go to Other Objects.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
Creating an Example Android App in Android Studio Activity lifecycle & UI Resources.
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,
1 3 Computing System Fundamentals 3.4 Networked Computer Systems.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
Activities and Intents Richard S. Stansbury 2015.
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
Web APIs By Behrooz and Corey mins... Punch It!! We will give a brief overview of the following topics: WebView WebSettings WebViewClient WebChromeClient.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
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.
Cosc 5/4735 YouTube API. YouTube The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications.
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.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Lab7 – Appendix.
Introduction to android
Permissions.
Android Programming - Features
Location-Based Services: Part 2 (Google Maps)
Mobile Development Workshop
GUI Programming Fundamentals
WebView and Web Services
Activities and Intents
Android 5: Assignment 1, First Half, Arithmetic Operations and Exceptions.
Android – Read/Write to External Storage
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Activities and Intents
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Adding Components to Activity
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Activities, Fragments, and Intents
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Networking: Part 1 (Web Content)

Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine used by Google Chrome. –Versions of Android prior to 4.4 (KitKat) were based on the WebKit open source web browser engine A view class, WebView, that can be used within an activity for displaying web content. Like the full-featured web browser, WebView also uses Chromium to render the web content. Standard Java features in package java.net for network access using TCP/IP sockets. Slide 2©SoftMoore Consulting

Launching an Internet Browser An Internet browser can be launched to display a web page by starting an activity with an intent whose action is ACTION_VIEW and whose data that is in the form of a URL. Uri uri = Uri.parse(" Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); If the URL is entered by the user as part of the application, then the following soft keyboard options should be used for the EditText field: –android:inputType="textUri" (provides ".com" and "/") –android:imeOptions="actionGo" (provides a "Go" button) Slide 3©SoftMoore Consulting

Class WebView Class WebView (in package android.webkit ) provides the ability to view web content within a portion of an activity’s screen. By default, some browser-related features such as JavaScript are disabled, but it is possible for an application to enable them when the view is created. In order to access the Internet, the following permission must be added to AndroidManifest.xml before the tag. Slide 4©SoftMoore Consulting

Defining a WebView in the Layout File (e.g., in activity_main.xml ) <WebView xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" /> Slide 5©SoftMoore Consulting Note: A web view can be the root element for the xml file; i.e., it does not have to be nested within a layout element. If defined as the root element, it must include the namespace (“ xmlns ”) attribute.

Loading a URL private WebView public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = (WebView) findViewById(R.id.webview); // enable JavaScript webView.getSettings().setJavaScriptEnabled(true); // force links to open in WebView instead of browser webView.setWebViewClient(new WebViewClient()); webView.loadUrl(" } Slide 6©SoftMoore Consulting

Example: WebView Slide 7©SoftMoore Consulting

Loading HTML Defined Within the Application private static final String HELLO_HTML = " Hello, Android! ";... public void onCreate(Bundle savedInstanceState) {... webView.loadData(HELLO_HTML, "text/html", "utf-8"); } Slide 8©SoftMoore Consulting

Enhancing a WebView: Navigating Back to a Previous Page To allow navigation back to a previous pages, handle the “back” button on the device so that it will return to the previous page rather than exit the public void onBackPressed() { if(webView.canGoBack()) webView.goBack(); else super.onBackPressed(); } Slide 9©SoftMoore Consulting Note: Older guides/tutorials might recommend using the onKeyDown() method and checking for KEYCODE_BACK, but the above is the preferred way to handle the “back” button.

Relevant Links Building Web Apps in WebView Getting Started: WebView-based Applications for Web Developers Android WebView Tutorial Slide 10©SoftMoore Consulting