Cosc 4755 Blackberry and Android Embedding the browser in your app.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
A Large-Scale Study of Mobile Web App Security Patrick Mutchler, Adam Doupe, John Mitchell, Chris Kruegel, Giovanni Vigna.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Development (Basics)
Charles Petzold Navigation.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Sage CRM Developers Course
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
JavaScript & jQuery the missing manual Chapter 11
CS378 - Mobile Computing Web - WebView and Web Services.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
© 2007 IBM Corporation IBM Global Engineering Solutions IBM Blue Gene/P Blue Gene/P Navigator.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
ALLIANCE Administration 20 Oct 2009 (Based on Release 2.2) Michaël Petit.
Cosc 5/4730 Android Content Providers and Intents.
CS378 - Mobile Computing Intents.
CS378 - Mobile Computing Web - WebView and Web Services.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Cosc 5/4730 Android App Widgets. App Widgets App Widgets are miniature application views that can be embedded in other applications (such as the Home.
CS378 - Mobile Computing Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Tabbed Views UITabBarController. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and.
® IBM Software Group © 2006 IBM Corporation JSF Progress Bar This Learning Module shows how to integrate EGL/JSF functionality into a run-time progress.
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.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Web Development 101 Presented by John Valance
How does Drupal Work? Information Systems 337 Prof. Harry Plantinga.
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,
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
Web Application in Android Ajay Babar. Contents 1.Introduction to Web Content 2. WebView widget I.What is webview. II. Properties(Methods) of Webview.
Cosc 5/4730 Android Maps v2 Blackberry Maps. Android.
WaveMaker Visual AJAX Studio 4.0 Training Java Script Events.
Web APIs By Behrooz and Corey mins... Punch It!! We will give a brief overview of the following topics: WebView WebSettings WebViewClient WebChromeClient.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Intro Web Applications Andrew Benson – ScottyLabs – CrashCourse F14.
© 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 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
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.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
WebView and JavaScript
Google VR (gvr) CardBoard and DayDream With OpenGL
Android Programming - Features
Android Application Web 1.
Not a Language but a series of techniques
Data Virtualization Tutorial… CORS and CIS
WebView and Web Services
Browser Engine How it works…..
Introduction to JavaScript
CIS 136 Building Mobile Apps
Presentation transcript:

Cosc 4755 Blackberry and Android Embedding the browser in your app

Embedding the browser For many applications, you may not nothing more then the web browser – But you want your “Company Name” on it – The company web server can now serve all the contain needed. Almost never have to update the app with new stuff. But the company web server, must serve the data that is in the “size of the screen”.

Browser object Android webkit – android.webkit WebView, a simple but very powerful widget Blackberry – net.rim.device.api.browser.field powerful, but complex. – Requires code signing to use outside the simulator – net.rim.device.api.browser.field2 V BrowserField, simple but very powerful field – does NOT require code signing.

ANDROID

Android webkit In the simplest form – Put a WebView Widget in the layout – If you want javascript enabled mWebView. getSettings().setJavaScriptEnabled(true); – Now load a page mWebView.loadUrl(" In androidManifest.xml, you need to request permission to use the internet. – Add this

Android webkit (2) How to handle everything else. – In the previous slide, if a use clicks on a link, the android browser will now open and you app is paused. To better control the browser you extend the WebViewClient class – Then add that to the WebView mWebView.setWebViewClient(new myWebViewClient());

WebViewClient This controls the functions and gives you app’s notifications about what is going on. – boolean shouldOverrideUrlLoading(WebView view, String url) Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. – return true, if handled, otherwise false. – onReceivedError(WebView view, int errorCode, String description, String failingUrl) Report an error to the host application. – Other that maybe useful onPageStarted, onPageFinished, onReceivedSslError, shouldOverrideKeyEvent, onUnhandledKeyEvent

WebViewClient Example private class CallBack extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { browser.loadUrl(url); return true; } I’ve only overriding one method, since I wanted to prevent the web browser from launching.

WebView methods reload(), which refreshes the page goBack(), which goes back one step in the browser history – canGoBack() returns true if there is at least one step back in the history goForward(), which goes forward one step in the browser history – canGoForward(), returns true if you can. ZoomIn(), ZoomOut(), stopLoading(), clearcache() and clearHistory() just to name a few.

WebViewClient example 2 //continuing the example, we add a keylistener to handle the back public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { mWebView.goBack(); return true; } return super.onKeyDown(keyCode, event); } We can also create buttons, for refresh, forward, and back. – Even a progress bar using the getProgress() method in WebView.

The Rest Cache – CacheManager and CacheManger.CacheResult gives you access in the browser cache system Cookies – CookieManager and CookieSyncManger gives you access to the cookies WebSettings – Gives you access to dozens of settings, including – To enable the built-in zoom, set WebSettings.setBuiltInZoomControls(boolean) – Change the UserAgentString – This is also where the javascript settings are as well. – Can use mWebView.getSettings() which returns a WebSettings object which can be used to control the settings.

BLACKBERRY

BrowserField We are going to skip over browser.field and use the browser.field2 package. To use the basics – Declare the BrowserField and add it to the screen. – BrowserField.requestContent(URL); The content of the webpage will be displayed on the screen, using the whole screen – Assuming it is the only field added.

Configuring. By default most things are turned on with the browserfield. – Use BrowserFieldConfig object to configure BrowserFieldConfig config = new BrowserFieldConfig(); config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE); //default is false config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENAB LED, Boolean.TRUE); //default is already true. config.setProperty(BrowserFieldConfig.ENABLE_COOKIES, Boolean.TRUE); //default is already true. browser = new BrowserField(config);

BrowserField (2) You can use the following to control what is displayed in the field – go forward or back on page forward(), back() – fresh() – setZoomScale(float scale) and float getZoomScale() to control how the page is zoomed. – A note, when browserfield has focus, the BB menu will allow the user to zoom fully out, when it has been “zoomed in”.

BrowserField (3) BrowserFieldHistory getHistory() – which returns the browser history of current field Document getDocuement() – returns a Document object (xml), which is likely a subinterface HTMLDocument object. getDocumentTitle() and getDocumentUrl() – returns a String with the info BrowserFieldListener – A listener how the page is “working”

BrowserFieldHistory Methods in the BrowserFieldHistory object boolean canGoBack() – This method returns true iff there are pages backwards in the history goBack() – This method will find the previous page loaded into this BrowserField instance and reload it boolean canGoForward() – This method returns true iff there are pages forwards in the history goForward() – This method will find the next page in this BrowserField instance's history and reload it go(int distance) – This method will find the page a certain distance forward or backwards from the current page and load that pages clearHistory() and refresh()

BrowserFieldHistory Example Check the history to see if we can go back one page BrowserFieldHistory browserFieldHistory = browser.getHistory(); if(browserFieldHistory.canGoBack()) { //causes the bowserfield to back one. browserFieldHistory.goBack(); } OR browser.back() //goes back one page if it can.

BrowserFieldListener These are the methods can be overriding by extending BrowserFieldLisetner – documentAborted(BrowserField browserField, Document document) – documentCreated(BrowserField browserField, ScriptEngine scriptEngine, Document document) – documentError(BrowserField browserField, Document document) – documentLoaded(BrowserField browserField, Document document) – documentUnloading(BrowserField browserField, Document document) – downloadProgress(BrowserField browserField, ContentReadEvent event) Except there is no documentation about when/why they are called. – DocumentLoaded is called when the BrowserField has finished loading – DocumentError seems to be called when the document fails to load

Q A &