Android Tutorial: Part 3

Similar documents
Android Tutorial: Part 2

Overloading Java Interface Callback Protocol User Command Handler Concurrent Thread

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

Getting Started With Android Feature Flags

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

UNDERSTANDING ACTIVITIES

LifeStreet Media Android Publisher SDK Integration Guide

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

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

shared objects monitors run() Runnable start()

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

Android/Java Lightning Tutorial JULY 30, 2018

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Accelerating Information Technology Innovation

Intents. Your first app assignment

Chapter 5 Flashing Neon FrameLayout

Android HelloWorld - Example. Tushar B. Kute,

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Basic GUI elements - exercises

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

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

ANDROID PROGRAMS DAY 3

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

Android Application Development. By : Shibaji Debnath

INTRODUCTION TO ANDROID

Studying software design patterns is an effective way to learn from the experience of others

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

Exercise 1: First Android App

Introduction To JAVA Programming Language

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

Android Programming Lecture 2 9/7/2011

COMP61242: Task /04/18

Android Programs Day 5

ELET4133: Embedded Systems. Topic 15 Sensors

Android writing files to the external storage device

EMBEDDED SYSTEMS PROGRAMMING Android Services

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

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

Embedded Systems Programming - PA8001

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Mobile Programming Lecture 1. Getting Started

Java Basics A Simple Hit the Zombies Game

Starting Another Activity Preferences

About 1. Chapter 1: Getting started with dagger-2 2. Remarks 2. Versions 2. Examples 2. Description and Setup 2. Basic Example 3.

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

Fragments. Lecture 11

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Introduction to Android Development

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

M.A.D Assignment # 1

Login with Amazon. Getting Started Guide for Android apps

Lab 3. Accessing GSM Functions on an Android Smartphone

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

Lab 1: Getting Started With Android Programming

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

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


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

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

Our First Android Application

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

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

XML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.

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

CMSC436: Fall 2013 Week 3 Lab

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

Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5

Android Application Model I

Arise Documentation. Release 2.7. Arise.io

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

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

Text Properties Data Validation Styles/Themes Material Design

CS 234/334 Lab 1: Android Jump Start

Mobile Application Development

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence

API Guide for Gesture Recognition Engine. Version 2.0

Cheetah Orion Ad Platform SDK Guide (for Android) V1.0

Multiple Activities. Many apps have multiple activities

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

BlackBerry Developer Global Tour. Android. Table of Contents

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

Solving an Android Threading Problem

Linkify Documentation

Upon completion of the second part of the lab the students will have:

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

Mobile User Interfaces

Lifecycle Callbacks and Intents

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

Lecture 6: Android XML, Inversion of Control, Timers (Handlers), Activity

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

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

android-espresso #androidespresso

Cordova (Phonegap) Installing Cordova (Phonegap)

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.

The Suggest Example layout (cont ed)

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

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

Mobile Computing Practice # 2c Android Applications - Interface

Orientation & Localization

Android UI Development

Transcription:

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 folder P5.1 to P5.2\v1 (create a new folder P5.2\v1). Copy the folders client, servermessagehandler, usercommandhandler, and userinterface from the Netbeans project folder P4.3\Client to the appropriate folder contained within the folder P5.2\v1. Be sure that source implements the changes discussed in class: protocol, interface, overloading, user command handler thread, setport, and setip. Start Andriod Studio and open the project P5.2/v1. Descend into each new java folder client, servermessagehandler, usercommandhandler, and userinterface and rename the packages, prepending com.ferens.ken (as appropriate) to every reference to the old package names. Note that changing the package names is the only change required to introduce the TCP/IP Client layer software to the Android GUI. 2

Step 2: Changes in the GUI Instantiate the TCP/IP Client Objects In the MainActivity.jav file, in method oncreate instantiate the classes Client and UserCommandHandler. Ensure that a myusercommandhandler reference variable is declared in the MainActivity class. This variable is needed by the GUI to send user commands to the handler. In the MainActivity.java file, specify that the MainActivity class implements com.ferens.ken.userinterface.userinterface (as appropriate). 3

Step 3.1: Changes in the GUI Implement the Update Method and Handler Create a concrete update() method. The body of this method should create a handler, as discussed in class, as follows: public void update(string thestring) { Message msg = new Message(); msg.obj = thestring; msg.settarget(myservermessagetextboxhandler); myservermessagetextboxhandler.sendmessage(msg); @SuppressLint("HandlerLeak") Handler myservermessagetextboxhandler=new Handler() { @Override public void handlemessage(message msg) { myservermessagetextbox.append(msg.obj +"\n"); ; 4

Step 3.2: Changes in the GUI Implement the Update Method and Handler Create a concrete update() method. The body of this method should create a handler, as discussed in class, as follows: public void update(string thestring) { ServerMessageTextBoxString = thestring; myservermessagetextboxhandler.sendemptymessage(7777); Handler myservermessagetextboxhandler=new Handler() { @Override public void handlemessage(message msg) { if(msg.what==7777) ; myservermessagetextbox.append(getservermessagetextboxstring()+"\n"); 5

Step 4: Changes in the GUI Server Messages Text BoX ID Declare a TextView instance variable myservermessagetextbox in the MainActivity class. In the oncreate method, get the ID of the server messages TextBox, as follows: myservermessagetextbox = (TextView)findViewById(R.id.ServerMessageTextBox); 6

Step 4: Changes in the GUI Server Messages Text BoX ID public class MainActivity extends AppCompatActivity implements com.ferens.ken.userinterface.userinterface { com.ferens.ken.usercommandhandler.usercommandhandler myusercommandhandler; TextView myservermessagetextbox; @Override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // you may have other statements com.ferens.ken.client.client myclient = new com.ferens.ken.client.client ( (int)7777, (String)"130.179.231.109", this); myusercommandhandler = new com.ferens.ken.usercommandhandler. UserCommandHandler(this, myclient); myservermessagetextbox = (TextView)findViewById(R.id.ServerMessageTextBox); 7

Step 5: Changes in the GUI Permissions In the AndroidManifest.xml file, add permission (before the application xml tag) to use the Internet: //<uses-permission android:name="android.permission.access_wifi_state" /> //<uses-permission android:name="android.permission.change_wifi_state" /> //<uses-permission android:name="android.permission.change_network_state" /> <uses-permission android:name="android.permission.internet" /> //<uses-permission android:name="android.permission.access_network_state" /> 8

Step 6: Changes in the GUI User Command Handlers For each handler in your Client app, get the value of the widget and send the appropriate String message to the handleusercommand() method of the UserCommandHandler object. For example: public void portnumberbuttonhandler(view view) { EditText myporttextbox; String myport; myporttextbox = (EditText)findViewById( R.id.portNumberEditText); myport = myporttextbox.gettext().tostring(); myusercommandhandler.handleusercommand ("SetPortNumber "+myport); 9

Start the associated server, and take note of the IP address and the port number of your server. Find network IP address using ipconfig Or use 10.0.2.2 Run the app. You should have no errors and the emulator should be displaying your user interface. Enter the port number and IP Address of your server. You should get the server acknowledge message when you tap on the Connect button in your GUI client. 10