Client / Server Programming in Android Eclipse IDE Android Development Tools (ADT) Android SDK

Slides:



Advertisements
Similar presentations
@2011 Mihail L. Sichitiu1 Android Introduction Hello Socket Programming TCP and UDP.
Advertisements

Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Android GUI Project John Hurley CS 454. Android 1. Android Basics 2. Android Development 3. Android UI 4. Hello, World 5. My Project.
App Development for Android Prabhaker Mateti. Development Tools (Android) Java – Java is the same. But, not all libs are included. – Unused: Swing, AWT,
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Android Application Development Tutorial. Topics Lecture 5 Overview Overview of Networking Programming Tutorial 2: Downloading from the Internet.
Android Programming. Outline Preparation Create new project Build and Run a project Debug a project Deploy on devices.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Mobile Programming Lecture 1 Getting Started. Today's Agenda About the Eclipse IDE Hello, World! Project Android Project Structure Intro to Activities,
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Wireless Mobility with Android 1 Presented by: Ung Yean MS. Computer Science American University, Washington DC, USA.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
CE Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running.
Android - Broadcast Receivers
Configuring Android Development Environment Nilesh Singh.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android App Basics Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5.
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Android and s Ken Nguyen Clayton state University 2012.
Resources & Android Manifest Калин Кадиев Astea Solutions AD.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Android apps development - Eclipse, Android SDK, and ADT plugin Introduction of.
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
CS499 – Mobile Application Development Fall 2012 Programming the Android Platform Application Fundamentals & Quick intro to XML & Anatomy of a Simple Android.
Android Programming.
Lab7 – Appendix.
Android Application Development
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android Application Development 1 6 May 2018
Android N Amanquah.
Adapting to Display Orientation
GUI Programming Fundamentals
Android Introduction Hello World.
Android Notifications
Android Widgets 1 7 August 2018
ITEC535 – Mobile Programming
Android – Read/Write to External Storage
תכנות ב android אליהו חלסצ'י.
Android GUI Project John Hurley CS 454.
CS323 Android Model-View-Controller Architecture
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android GUI Project John Hurley CS 454.
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Programski jezici za mobilne aplikacije
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Notifications
CMPE419 Mobile Application Development
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Client / Server Programming in Android Eclipse IDE Android Development Tools (ADT) Android SDK

TCP Echo Client (1) cs423- cotter2

Android Mobile Development 1.Install Eclipse IDE 2.Install Android Development Tools (ADT) 3.Install Android SDK 4.Install specific Android Versions through SDK Manager 5.Create / install an Android Virtual Device (AVD) cs423- cotter3

Android SDK / AVD Managers cs423- cotter4

Android SDK Manager cs423- cotter5

AVD Manager cs423- cotter6

From file menu, select “New” then “Project” cs423- cotter7

Identify project name cs423- cotter8

Identify the desired SDK (based on the target device) cs423- cotter9

Provide a unique package name (reverse Domain Name + project) cs423- cotter10

Empty Project Configuration cs423- cotter11

Main.xml – Graphical Layout Empty Project cs423- cotter12

Main.xml – Graphical Layout Completed Project cs423- cotter13

Main.xml cs423- cotter14

EchoClientActivity.xml cs423- cotter15

Strings.xml cs423- cotter16

AndroidManifest.xml cs423- cotter17

Base Android 2.2 Phone VD cs423- cotter18

Base Android 2.2 Phone VD cs423- cotter19

UDP Echo Client (1) cs423- cotter20

UDP Echo Client (2) cs423- cotter21

UDP Echo Client (3) cs423- cotter22

echoClient.apk cs423- cotter23

EchoClientActivity.java package edu.umkc.cotterr.echo; import android.app.Activity; android.os.Bundle; android.view.View; android.widget.EditText; android.widget.Toast; java.net.*; java.io.*; import edu.umkc.cotterr.echo.R; public class EchoClientActivity extends Activity { /** Called when the activity is first created. */ private EditText portNumber; private EditText hostName; private EditText inputMsg; private EditText resultMsg; private InetAddress ia; private Socket mySocket; private InputStream isIn; private PrintStream psOut; private byte abIn[]; cs423- cotter24

EchoClientActivity.java public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); hostName = (EditText) findViewById(R.id.editText1); portNumber = (EditText) findViewById(R.id.editText2); resultMsg = (EditText) findViewById(R.id.editText3); inputMsg = (EditText) findViewById(R.id.editText4); } cs423- cotter25

EchoClientActivity.java public void myEchoHandler(View view) { switch (view.getId()) { case R.id.button1: /* This is the connect button String sHostName = hostName.getText().toString(); int iPortNumber = Integer.parseInt(portNumber.getText().toString()); try { ia = InetAddress.getByName(sHostName); mySocket = new Socket (ia, iPortNumber); Toast.makeText(this,"We are now connected to: " + hostName + "\n", Toast.LENGTH_LONG).show(); } catch (Exception ex) { Toast.makeText(this,"Connect to " + hostName + "failed. Exception" + ex + "\n", Toast.LENGTH_LONG).show(); } break; cs423- cotter26

EchoClientActivity.java case R.id.button2: /* This is the send data button */ String sResponse, sTemp String sInputMsg = inputMsg.getText().toString(); int iNumRead; abIn = new byte[1024]; try { isIn = mySocket.getInputStream(); psOut = new PrintStream(mySocket.getOutputStream()); psOut.print(sInputMsg); iNumRead = isIn.read(abIn,0,1024); sTemp = new String(abIn, 0, iNumRead); sResponse = "We got back: " + sTemp; resultMsg.setText(sResponse); } catch (Exception ex) { Toast.makeText(this,"Send data failed. Exception" + ex + "\n", Toast.LENGTH_LONG).show(); } break; cs423- cotter27

EchoClientActivity.java case R.id.button3: // This is the quit button. String sTemp2; try { mySocket.close(); inputMsg.setText(""); sTemp2 = new String ("Goodbye..."); resultMsg.setText(sTemp2); } catch (Exception ex) { Toast.makeText(this,"Close socket failed. Exception“ + ex + "\n", Toast.LENGTH_LONG).show(); } } //end of switch } //end of myEchoHandler } //end of EchoClientActivity cs423- cotter28

R.java package edu.umkc.cotterr.echo; public final class R { public static final class attr { } public static final class color { public static final int backgroundColor=0x7f050000; } public static final class drawable { public static final int ic_launcher=0x7f020000; } public static final class layout { public static final int main=0x7f030000; } cs423- cotter29

R.java public static final class id { public static final int button1=0x7f060004; public static final int button2=0x7f060008; public static final int button3=0x7f060009; public static final int editText1=0x7f060001; public static final int editText2=0x7f060003; public static final int editText3=0x7f06000b; public static final int editText4=0x7f060006; public static final int linearLayout1=0x7f060007; public static final int textView1=0x7f060000; public static final int textView2=0x7f060002; public static final int textView3=0x7f060005; public static final int textView4=0x7f06000a; } cs423- cotter30

R.java public static final class string { public static final int ConvertButton=0x7f040002; public static final int DefaultHost=0x7f040003; public static final int DefaultPort=0x7f040004; public static final int app_name=0x7f040001; public static final int connectButton=0x7f040007; public static final int hello=0x7f040000; public static final int hostname=0x7f040005; public static final int input=0x7f040008; public static final int port=0x7f040006; public static final int quit=0x7f04000b; public static final int result=0x7f040009; public static final int send=0x7f04000a; } cs423- cotter31

main.xml <LinearLayout xmlns:android=" android:layout_width="fill_parent“ android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="wrap_content“ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="201dp" android:layout_height="wrap_content“ android:inputType="text" > cs423- cotter32

main.xml <TextView android:layout_width="wrap_content“ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="73dp" android:layout_height="wrap_content" android:inputType="text" android:width="100dp" /> <Button android:layout_width="wrap_content“ android:layout_height="wrap_content" android:onClick="myEchoHandler" /> cs423- cotter33

main.xml <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:inputType="text" android:layout_height="wrap_content" /> cs423- cotter34

main.xml <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="myEchoHandler" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="myEchoHandler"/> cs423- cotter35

main.xml <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:height="100dp" android:inputType="textMultiLine" /> cs423- cotter36

strings.xml Hello World, EchoClientActivity! Bob\'s EchoClient # Convert localhost 3456 Hostname Port Connect User Input Echo Results Send Echo Exit Echo cs423- cotter37

AndroidManifest.xml <manifest xmlns:android=" package="edu.umkc.cotterr.echo" android:versionCode="1" android:versionName="1.0" > <application > <activity android:name=".EchoClientActivity" > cs423- cotter38

Summary Android Development has strong support in Eclipse IDE Core Android language is Java, with a full library of Android classes cs423- cotter39