SlideShare a Scribd company logo
Android Overview




   Dongsu Han
                   1
Outline
•   Java network programming overview
•   Android Overview
•   Android Emulator Overview
•   Project Overview
•   Getting Started




                                        2
Java Network Programming
• Java.net.* programming model
  – Blocking model, you wait until work is done, maybe
    forever
  – One thread required per connection
  – Socket exposes input and output stream
• Java.nio.* programming model
  – Introduced in Java 1.4, non-blocking IO
  – New Interface: SocketChannel (in java.nio.channels)
  – Reading/writing via Buffer objects rather than
    input/output streams
  – Select() implemented
                                                          3
Java.net.* Socket API
• Part of the java.net package
  – import java.net.*;
• Provides two classes of sockets for TCP
  – Socket : client side of socket
  – ServerSocket : server side of socket
• Provides one socket type for UDP
  – DatagramSocket


                                            4
Java.net.Socket
• Making a connection
  Socket s = new Socket(“hostname”, port);
• The constructor not only creates a socket, but
  makes a TCP connection.
• Socket exposes input and output stream.
  s.getOutputStream()
  s.getInputStream()
• Most of the time you'll chain the input/output
  stream to some other input/output stream or
  reader object to more easily handle the data.
                                                   5
Java.net.Socket
• Create a print stream for writing
   – OutputStream rawOut =
     socket.getOutputStream();
   – PrintStream pout = new PrintStream(rawOut);
• Create a data output stream for writing
   – BufferedOutputStream buffOut = new
     BufferedOutputStream(rawOut);
   – out =new DataOutputStream(buffOut);
• Create a data input stream for reading
  DataInputStream din =
  new DataInputStream(socket.getInputStream());
                                                   6
Java.net.ServerSocket
• Server Side socket
• To support multiple clients servers have
  at least one thread per client
  ServerSocket svr = new ServerSocket(port);
  while (Socket s = svr.accept())
 {
     new EchoThread(s).start();
 }

                                               7
Java.net and Thread
class EchoThread extends Thread {

    EchoThread(Socket s) { ... }

    public void run() {
    // waits for data and reads it in until connection dies
    // readLine() blocks until the server receives a new line from client

        String s;
        while ((s = in.readLine()) != null) {
            out.println(s);
        }
    }
}
                                                                            8
Reference for Java Network
           Programming

• http://java.sun.com/docs/books/tutorial/net
  working/sockets/index.html




                                                9
Android
• Software platform on mobile device by Open
  Handset Alliance (Google)
• Developing language is Java
• Linux kernel (Open Source)
• Provides a development kit (SDK)
• Emulator support with some limitation



                                               10
Developing Android Application
• There are four building blocks to an Android
  application:
  – Activity
  – Service
  – Broadcast Intent Receiver
  – Content Provider


• http://code.google.com/android/intro/anatomy.html

                                                  11
Developing Android Application
• Activity
   – Controls a single screen
   – Usually starts up with an app, multiple Activity(screen) is
     associated to an app
   – Intent is used to move from screen to screen
• Service
   – A Service is code that is long-lived and runs without a UI
   – E.g. Network I/O, playback of media files
• Not using these components correctly can result in the system killing
  the application's process while it is doing important work.
                                                                     12
Project 1
• Description
  – Develop a file sharing application where updates get
    synchronized when users come across within
    communication range


• Checkpoint
  – Implement service discovery
  – Establish a TCP connection between every pair of
    nodes in range
  – Due Feb 5. 2 weeks from now.

                                                           13
Getting Started
• Setting up the environment (Installation)
  – Section 3.1 of the project document
  – Use the pre-installed binaries on AFS
  – Copy the binaries from AFS
  – Install yourself
• Need eclipse, Java SDK 1.5/1.6, android SDK,
  eclipse plug-in


                                                 14
Getting Started
• Starting the project on Eclipse
   – Download project file
   – Open the project in Eclipse (read the documentation)
• Running the local server
   – Local server controls the connection between Android
     emulators
   – Implemented in Ruby binds port 10001 ~ 10010
   – Need eventmachine Ruby lib
   – setenv RUBYLIB
     /afs/cs.cmu.edu/project/cmcl-srini-4/15-
     446/android/eventmachine-0.12.2/lib

                                                            15
Emulator




           16
Emulator
• Running the emulator
  – Stand-alone (./emulator)
  – Eclipse Plug-in (Just ‘Run’ it as Android application)
• Binds to port 5554~5580
  – Don’t run on shared machines
• adb (Android Debugging Bridge)
  – Using adb, we can connect to android’s shell
  – Logcat (demo)

                                                        17
Running multiple emulators
• Manual mode will let you do this
  – Menu: Run  Run Configurations
  – Go to Android Applications on the left tab and
    select FileSharerActivityProject
  – Click on Target tab and select “maunal” mode
  – When you run you can specify to launch a new
    emulator or use existing ones to run the app
• To use adb you have to specify the emulator
  device name if there are multiple emulators
• #adb –s emulator-5554 shell
                                                     18
Configurations
• XML file defines a connectivity
<?xml version="1.0" encoding="UTF-8" ?>
<connectivity time="2" nodes="2">
   <connect node1="0" node2="1" at="1" />
</connectivity>




                                            19
Project API
• Broadcast Interface
  – BroadcastReceiveCallBack
  – CS446Bcast
• Socket API (blocking IO)
  – CS446ServerSocket
  – CS446Socket
• Util
  – getMyID() returns the ID of the emulator

                                               20
Broadcast Interface
• BroadcastReceiveCallBack
  – BcastMsgReceived(byte []msg, int srcID) gets
    called when a broadcast message is received from
    srcID. Msg is the byte array of the content.
• CS446Bcast
  – open() : returns CS446Bcast
  – send(byte [] msg): sends a broadcast message



                                                   21
Socket
• CS446ServerSocket
  – There can be only one server socket. ServerSocket
    always binds to port 0.
  – open(): returns a CS446ServerSocket
  – accept(): Listens for a incoming connection and
    returns a CS446Socket when a connection is
    established
  – close(): closes the socket
  – isClosed(): returns boolean

                                                    22
Socket
• CS446Socket
  – CS446Socket(int peerID): opens a socket and makes a
    connection to peerID, always use local port 1 remote
    port 0 when making a active connection
  – void close()
  – int getLocalPort()
  – int getPort()
  – int getPeerID()
  – int getLocalID()
  – OutputStream getOutputStream()
  – InputStream getInputStream()
                                                           23
2nd part of project 1
• You will be given a workload of users updating
  file.
• You will need to keep a version vector and
  synchronize the content.
• Details will be posted soon




                                               24

More Related Content

What's hot

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
Fabio Fumarola
 
Distributed Elixir
Distributed ElixirDistributed Elixir
Distributed Elixir
Óscar De Arriba González
 
Docker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental NetworkingDocker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental Networking
Sreenivas Makam
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
Open stackaustinmeetupsept21
Open stackaustinmeetupsept21Open stackaustinmeetupsept21
Open stackaustinmeetupsept21
Brent Doncaster
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking features
strikr .
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4
aminmesbahi
 
Testing Docker Security Linuxlab 2017
Testing Docker Security Linuxlab 2017Testing Docker Security Linuxlab 2017
Testing Docker Security Linuxlab 2017
Jose Manuel Ortega Candel
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
Zygmunt Krynicki
 
Introduction to Docker
Introduction  to DockerIntroduction  to Docker
Introduction to Docker
Jian Wu
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and Docker
Danish Khakwani
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
dotCloud
 
DSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
DSD-INT 2015- Open source pre and postprocessing workshop- Bert JagersDSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
DSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
Deltares
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
Emertxe Information Technologies Pvt Ltd
 
Docker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know nowDocker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know now
PLUMgrid
 
Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013OpenNebula Project
 
Docker basics
Docker basicsDocker basics
Docker basics
Claudio Montoya
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
Ilya Shakhat
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
Mike Pittaro
 
Docker introduction for Carbon IT
Docker introduction for Carbon ITDocker introduction for Carbon IT
Docker introduction for Carbon IT
yannick grenzinger
 

What's hot (20)

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
 
Distributed Elixir
Distributed ElixirDistributed Elixir
Distributed Elixir
 
Docker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental NetworkingDocker Networking - Current Status and goals of Experimental Networking
Docker Networking - Current Status and goals of Experimental Networking
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Open stackaustinmeetupsept21
Open stackaustinmeetupsept21Open stackaustinmeetupsept21
Open stackaustinmeetupsept21
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking features
 
.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4.NET Core, ASP.NET Core Course, Session 4
.NET Core, ASP.NET Core Course, Session 4
 
Testing Docker Security Linuxlab 2017
Testing Docker Security Linuxlab 2017Testing Docker Security Linuxlab 2017
Testing Docker Security Linuxlab 2017
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
 
Introduction to Docker
Introduction  to DockerIntroduction  to Docker
Introduction to Docker
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and Docker
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
 
DSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
DSD-INT 2015- Open source pre and postprocessing workshop- Bert JagersDSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
DSD-INT 2015- Open source pre and postprocessing workshop- Bert Jagers
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 
Docker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know nowDocker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know now
 
Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013Getting Started Hacking OpenNebula - Fosdem-2013
Getting Started Hacking OpenNebula - Fosdem-2013
 
Docker basics
Docker basicsDocker basics
Docker basics
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 
Docker introduction for Carbon IT
Docker introduction for Carbon ITDocker introduction for Carbon IT
Docker introduction for Carbon IT
 

Similar to 04 android

Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoT
Benjamin Cabé
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Adam Dunkels
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
Rami Sayar
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
EliasPetros
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
Kyle Cearley
 
Distributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-REDDistributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-RED
Michael Blackstock
 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
SmitaBorkar9
 
Chap 1 Network Theory & Java Overview
Chap 1   Network Theory & Java OverviewChap 1   Network Theory & Java Overview
Chap 1 Network Theory & Java Overview
Ministry of Higher Education
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
Vagif Abilov
 
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivityIoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
Samsung Open Source Group
 
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
WithTheBest
 
A Science Project: Swift Serial Chat
A Science Project: Swift Serial ChatA Science Project: Swift Serial Chat
A Science Project: Swift Serial Chat
yeokm1
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
A.java
A.javaA.java

Similar to 04 android (20)

Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
Multi user chat system using java
Multi user chat system using javaMulti user chat system using java
Multi user chat system using java
 
Java adv
Java advJava adv
Java adv
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoT
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
5_6278455688045789623.pptx
5_6278455688045789623.pptx5_6278455688045789623.pptx
5_6278455688045789623.pptx
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
Distributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-REDDistributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-RED
 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
 
Chap 1 Network Theory & Java Overview
Chap 1   Network Theory & Java OverviewChap 1   Network Theory & Java Overview
Chap 1 Network Theory & Java Overview
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
 
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivityIoT: From Arduino Microcontrollers to Tizen Products using IoTivity
IoT: From Arduino Microcontrollers to Tizen Products using IoTivity
 
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
IoT: From Arduino MicroControllers to Tizen Products Using IoTivity - Philipp...
 
Lecture10
Lecture10Lecture10
Lecture10
 
A Science Project: Swift Serial Chat
A Science Project: Swift Serial ChatA Science Project: Swift Serial Chat
A Science Project: Swift Serial Chat
 
javanetworking
javanetworkingjavanetworking
javanetworking
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
A.java
A.javaA.java
A.java
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

04 android

  • 1. Android Overview Dongsu Han 1
  • 2. Outline • Java network programming overview • Android Overview • Android Emulator Overview • Project Overview • Getting Started 2
  • 3. Java Network Programming • Java.net.* programming model – Blocking model, you wait until work is done, maybe forever – One thread required per connection – Socket exposes input and output stream • Java.nio.* programming model – Introduced in Java 1.4, non-blocking IO – New Interface: SocketChannel (in java.nio.channels) – Reading/writing via Buffer objects rather than input/output streams – Select() implemented 3
  • 4. Java.net.* Socket API • Part of the java.net package – import java.net.*; • Provides two classes of sockets for TCP – Socket : client side of socket – ServerSocket : server side of socket • Provides one socket type for UDP – DatagramSocket 4
  • 5. Java.net.Socket • Making a connection Socket s = new Socket(“hostname”, port); • The constructor not only creates a socket, but makes a TCP connection. • Socket exposes input and output stream. s.getOutputStream() s.getInputStream() • Most of the time you'll chain the input/output stream to some other input/output stream or reader object to more easily handle the data. 5
  • 6. Java.net.Socket • Create a print stream for writing – OutputStream rawOut = socket.getOutputStream(); – PrintStream pout = new PrintStream(rawOut); • Create a data output stream for writing – BufferedOutputStream buffOut = new BufferedOutputStream(rawOut); – out =new DataOutputStream(buffOut); • Create a data input stream for reading DataInputStream din = new DataInputStream(socket.getInputStream()); 6
  • 7. Java.net.ServerSocket • Server Side socket • To support multiple clients servers have at least one thread per client ServerSocket svr = new ServerSocket(port); while (Socket s = svr.accept()) { new EchoThread(s).start(); } 7
  • 8. Java.net and Thread class EchoThread extends Thread { EchoThread(Socket s) { ... } public void run() { // waits for data and reads it in until connection dies // readLine() blocks until the server receives a new line from client String s; while ((s = in.readLine()) != null) { out.println(s); } } } 8
  • 9. Reference for Java Network Programming • http://java.sun.com/docs/books/tutorial/net working/sockets/index.html 9
  • 10. Android • Software platform on mobile device by Open Handset Alliance (Google) • Developing language is Java • Linux kernel (Open Source) • Provides a development kit (SDK) • Emulator support with some limitation 10
  • 11. Developing Android Application • There are four building blocks to an Android application: – Activity – Service – Broadcast Intent Receiver – Content Provider • http://code.google.com/android/intro/anatomy.html 11
  • 12. Developing Android Application • Activity – Controls a single screen – Usually starts up with an app, multiple Activity(screen) is associated to an app – Intent is used to move from screen to screen • Service – A Service is code that is long-lived and runs without a UI – E.g. Network I/O, playback of media files • Not using these components correctly can result in the system killing the application's process while it is doing important work. 12
  • 13. Project 1 • Description – Develop a file sharing application where updates get synchronized when users come across within communication range • Checkpoint – Implement service discovery – Establish a TCP connection between every pair of nodes in range – Due Feb 5. 2 weeks from now. 13
  • 14. Getting Started • Setting up the environment (Installation) – Section 3.1 of the project document – Use the pre-installed binaries on AFS – Copy the binaries from AFS – Install yourself • Need eclipse, Java SDK 1.5/1.6, android SDK, eclipse plug-in 14
  • 15. Getting Started • Starting the project on Eclipse – Download project file – Open the project in Eclipse (read the documentation) • Running the local server – Local server controls the connection between Android emulators – Implemented in Ruby binds port 10001 ~ 10010 – Need eventmachine Ruby lib – setenv RUBYLIB /afs/cs.cmu.edu/project/cmcl-srini-4/15- 446/android/eventmachine-0.12.2/lib 15
  • 16. Emulator 16
  • 17. Emulator • Running the emulator – Stand-alone (./emulator) – Eclipse Plug-in (Just ‘Run’ it as Android application) • Binds to port 5554~5580 – Don’t run on shared machines • adb (Android Debugging Bridge) – Using adb, we can connect to android’s shell – Logcat (demo) 17
  • 18. Running multiple emulators • Manual mode will let you do this – Menu: Run  Run Configurations – Go to Android Applications on the left tab and select FileSharerActivityProject – Click on Target tab and select “maunal” mode – When you run you can specify to launch a new emulator or use existing ones to run the app • To use adb you have to specify the emulator device name if there are multiple emulators • #adb –s emulator-5554 shell 18
  • 19. Configurations • XML file defines a connectivity <?xml version="1.0" encoding="UTF-8" ?> <connectivity time="2" nodes="2"> <connect node1="0" node2="1" at="1" /> </connectivity> 19
  • 20. Project API • Broadcast Interface – BroadcastReceiveCallBack – CS446Bcast • Socket API (blocking IO) – CS446ServerSocket – CS446Socket • Util – getMyID() returns the ID of the emulator 20
  • 21. Broadcast Interface • BroadcastReceiveCallBack – BcastMsgReceived(byte []msg, int srcID) gets called when a broadcast message is received from srcID. Msg is the byte array of the content. • CS446Bcast – open() : returns CS446Bcast – send(byte [] msg): sends a broadcast message 21
  • 22. Socket • CS446ServerSocket – There can be only one server socket. ServerSocket always binds to port 0. – open(): returns a CS446ServerSocket – accept(): Listens for a incoming connection and returns a CS446Socket when a connection is established – close(): closes the socket – isClosed(): returns boolean 22
  • 23. Socket • CS446Socket – CS446Socket(int peerID): opens a socket and makes a connection to peerID, always use local port 1 remote port 0 when making a active connection – void close() – int getLocalPort() – int getPort() – int getPeerID() – int getLocalID() – OutputStream getOutputStream() – InputStream getInputStream() 23
  • 24. 2nd part of project 1 • You will be given a workload of users updating file. • You will need to keep a version vector and synchronize the content. • Details will be posted soon 24