CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu

Similar documents
CS 4518 Mobile and Ubiquitous Computing Lecture 3: Android UI Design in XML + Examples. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3: Android UI, WebView, Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android. Emmanuel Agu

CS 403X Mobile and Ubiquitous Computing Lecture 3: Introduction to Android Programming Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 1b: Introduction to Android. Emmanuel Agu

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

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

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

Building MyFirstApp Android Application Step by Step. Sang Shin Learn with Passion!

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

App Development for Smart Devices. Lec #18: Advanced Topics

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

GUI Widget. Lecture6

This lecture. The BrowserIntent Example (cont d)

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

University of Stirling Computing Science Telecommunications Systems and Services CSCU9YH: Android Practical 1 Hello World

Produced by. Mobile Application Development. Eamonn de Leastar

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Lab 1 - Setting up the User s Profile UI

EMBEDDED SYSTEMS PROGRAMMING Application Basics

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

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

Introduction To Android

Mobile Programming Lecture 1. Getting Started

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

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

COMP4521 EMBEDDED SYSTEMS SOFTWARE

CS 234/334 Lab 1: Android Jump Start

ListView Containers. Resources. Creating a ListView

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Software Practice 3 Before we start Today s lecture Today s Task Team organization

LECTURE 08 UI AND EVENT HANDLING

CS 528 Mobile and Ubiquitous Computing Lecture 4b: Face Detection, recognition, interpretation + SQLite Databases Emmanuel Agu

Q.1 Explain the dialog and also explain the Demonstrate working dialog in android.

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

1. Simple List. 1.1 Simple List using simple_list_item_1

Android Application Development. By : Shibaji Debnath

Android Programs Day 5

ListView (link) An ordered collection of selectable choices. key attributes in XML:

Lecture 1 Introduction to Android. App Development for Mobile Devices. App Development for Mobile Devices. Announcement.

Group B: Assignment No 8. Title of Assignment: To verify the operating system name and version of Mobile devices.

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Playing Sound and Video Emmanuel Agu

Fragments. Lecture 10

Android/Java Lightning Tutorial JULY 30, 2018

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

<uses-permission android:name="android.permission.internet"/>

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

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

Android Beginners Workshop

Fragments. Lecture 11

Assignment 1: Port & Starboard

INTRODUCTION TO ANDROID

CS260 Intro to Java & Android 05.Android UI(Part I)

Using Eclipse for Android Development

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

CS260 Intro to Java & Android 05.Android UI(Part I)

App Development for Smart Devices. Lec #9: Advanced Topics

Android User Interface


LECTURE NOTES OF APPLICATION ACTIVITIES

ES E 3 3 L a L b 5 Android development

Android Tutorial: Part 3

Preview from Notesale.co.uk Page 13 of 72

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Android HelloWorld - Example. Tushar B. Kute,

Vienos veiklos būsena. Theory

Android Workshop: Model View Controller ( MVC):

Java Basics A Simple Hit the Zombies Game

ANDROID APPS DEVELOPMENT FOR MOBILE GAME

Workshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking

Android Application Model I

Lab 1: Getting Started With Android Programming

EMBEDDED SYSTEMS PROGRAMMING Android NDK

8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?

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

Linkify Documentation

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

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

Creating a User Interface

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

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

Mobile Development Lecture 10: Fragments

Eventually, you'll be returned to the AVD Manager. From there, you'll see your new device.

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Mobile User Interfaces

07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center

Transcription:

CS 4518 Mobile and Ubiquitous Computing Lecture 4: WebView (Part 2) Emmanuel Agu

WebView Widget

WebView Widget A View that displays web pages Can be used for creating your own web browser OR just display some online content inside your app Two rendering options: WebKit rendering engine (http://www.webkit.org/) Chromium (http://www.chromium.org/) Webkit used in many web browsers including Safari Chromium WebView supports HTML5, CSS3, and JavaScript 3

WebView Widget Functionality Display Web page containing HTML, CSS, Javascript Navigate previous URLs (back and forward) zoom in and out perform searches Can also: Embed images in page Search page for string Deal with cookies 4

WebView Example Simple app to view and navigate web pages XML code (e.g in res/layout/main.xml) 5

WebView Activity In oncreate, use loadurl to load website If website contains Javascript, enable Javascript loadurl( ) can also load files on Android local filesystem (file://)

WebView: Request Internet Access Request permission to use Internet in AndroidManifest.xml 7

Android UI Design Example

GeoQuiz App Reference: Android Nerd Ranch, pgs 1-32 App presents questions to test user s knowledge of geography User answers by pressing True or False buttons How to get this book? Question User responds by clicking True or False

GeoQuiz App 2 main files: activity_quiz.xml: to format app screen QuizActivity.java: To present question, accept True/False response AndroidManifest.xml lists all app components, auto-generated

GeoQuiz: Plan Out App Widgets 5 Widgets arranged hierarchically

GeoQuiz: activity_quiz.xml File listing

GeoQuiz: strings.xml File listing Define app strings Question True False

QuizActivity.java Initial QuizActivity.java code oncreate Method is called once Activity is created specify layout XML file (activity_quiz.xml) Would like java code to respond to True/False buttons being clicked

Responding to True/False Buttons in Java Write code in Java file to specify app s response when True/False buttons are clicked

2 Alternative Ways to Respond to Button Clicks 1. In XML: set android:onclick attribute (already seen this) 2. In java create a ClickListener object, override onclick method typically done with anonymous inner class

Recall: Approach 1: Responding to Button Clicks 1. In XML file (e.g. Activity_my.xml), set android:onclick attribute to specify method to be invoked 2. In Java file (e.g. MainActivity.java) declare method/handler to take desired action

Approach 2: Create a ClickListener object, override onclick First, get reference to Button in our Java file. How? Need reference to Buttons

R.Java Constants During compilation, XML resources (drawables, layouts, strings, views with IDs, etc) are assigned constants Sample R.Java file In Java file, can refer to these resources using their constants

Referencing Widgets by ID To reference a widget in Java code, use findviewbyid need its android:id Use findviewbyid In XML file, give the widget/view an ID i.e. assign android:id In java file, to reference/manipulate view/widget use its ID to find it (call findviewbyid( ) )

Getting View References Argument of findviewbyid is constant of resource A generic view is returned (not subclasses e.g. buttons, TextView), so needs to cast

QuizActivity.java: Getting References to Buttons To get reference to buttons in java code Declaration in XML

QuizActivity.java: Setting Listeners Set listeners for True and False button 2.Set Listener Object For mtruebutton 3. Overide onclick method (insert your code to do whatever you want as mouse response here) 1. Create listener object as anonymous (unnamed) inner object

QuizActivity.java: Adding a Toast A toast is a short pop-up message Does not require any input or action After user clicks True or False button, our app will pop-up a toast to inform the user if they were right or wrong First, we need to add toast strings (Correct, Incorrect) to strings.xml A toast

QuizActivity.java: Adding a Toast To create a toast, call the method: Instance of Activity (Activity is a subclass of context) Resouce ID of the string that toast should display Constant to specifiy how long toast should be visible After creating toast, call toast.show( ) to display it For example to add a toast to our onclick( ) method:

QuizActivity.java: Adding a Toast Code for adding a toast 2.Set Listener Object For mtruebutton 3. Overide onclick method Make a toast 1. Create listener object as anonymous innner object

package com.bignerdranch.android.geoquiz; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.toast; public class QuizActivity extends Activity { Button mtruebutton; Button mfalsebutton; QuizActivity.java: Complete Listing @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_quiz); mtruebutton = (Button)findViewById(R.id.true_button); mtruebutton.setonclicklistener(new View.OnClickListener() { @Override public void onclick(view v) { Toast.makeText(QuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show(); } });

mfalsebutton = (Button)findViewById(R.id.false_button); mfalsebutton.setonclicklistener(new View.OnClickListener() { } @Override public void onclick(view v) { Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show(); } }); @Override public boolean oncreateoptionsmenu(menu menu) { QuizActivity.java: Complete Listing (Contd) // Inflate the menu; // this adds items to the action bar if it is present. } getmenuinflater().inflate(r.menu.activity_quiz, menu); return true; } Used if app has an Action bar menu

Quiz 1

Quiz 1 Quiz in class next Monday (before class Mon, 1/23) Short answer questions Try to focus on understanding, not memorization Covers: Lecture slides for lectures 1-4 YouTube Tutorials (from thenewboston) 1-8, 11,12, 17 3 code examples from books HFAD examples: myfirstapp, Beer Advisor ANR example: geoquiz

EML: Cooperative Based Groups

EML: Cooperative Based Groups Japanese students visiting Boston for 2 week vacation Speak little English, need help to find Attractions to visit, where to stay (cheap, central), meet Americans, getting around, eat (Japanese, some Boston food), weather info, events,.. anything Your task: Search android market for helpful apps (6 mins) Location-aware: 5 points Ubicomp (e.g. uses sensor) or smartwatch: 10 points Also IoT devices they can buy that would help them

References Busy Coder s guide to Android version 4.4 CS 65/165 slides, Dartmouth College, Spring 2014 CS 371M slides, U of Texas Austin, Spring 2014 Android App Development for Beginners videos by Bucky Roberts (thenewboston)