::. Contenuti della lezione *+ ') $ &,!!!$!-,.../- ' % + &



Similar documents
Mobile application development J2ME U N I T I I

MIDlet development with J2ME and MIDP

Introduction to Mobile Phone. Programming in Java Me

Tutorial: Development of Interactive Applications for Mobile Devices

Mobile Application Development

JSR 82 BT APIs Prof. Dr. S. Heiss / 1. Bluetooth. JSR 82 Java APIs for Bluetooth Wireless Technology

javax.bluetooth java.obex (optional) Fakulta elektrotechniky a informatiky - Rygol Lukáš

An Overview of Java. overview-1

Development of Java ME

Mobile Software Application Development. Tutorial. Caesar Ogole. April 2006

Java Platform, Micro Edition (Java ME) Mokoena F.R. The 7046 Team

J2ME: Step by step. Presented by developerworks, your source for great tutorials ibm.com/developerworks

private byte[] encryptcommand = {(byte)0xa0, (byte)0xc1, (byte)0x00, (byte)0x00, (byte) 0x00};

Building a Multi-Threaded Web Server

Socket-based Network Communication in J2SE and J2ME

Network Communication

Programmation Orientée Objets. et langage Java

Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?

1 Mobile and Ubiquitous User Interfaces

! "# $%&'( ) * ).) "%&' 1* ( %&' ! "%&'2 (! ""$ 1! ""3($

Network/Socket Programming in Java. Rajkumar Buyya

Java Network. Slides prepared by : Farzana Rahman

Chapter 2 Introduction to Java programming

APPLICATION PROGRAMMING - MOBILE COMPUTING Mobile Computing

2 Categories of Constraints

DESIGNING SHIFT CALENDAR FOR MOBILE PHONE

Communicating with a Barco projector over network. Technical note

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer

Tutorial Reference Manual. Java WireFusion 4.1

Assignment 4 Solutions

JAVA - FILES AND I/O

Application Development with TCP/IP. Brian S. Mitchell Drexel University

Java from a C perspective. Plan

Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP

AVRO - SERIALIZATION

5. More on app development

Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1

Java Programming Fundamentals

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

JAVA Program For Processing SMS Messages

Mail User Agent Project

WRITING DATA TO A BINARY FILE

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Java Network Programming. The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol).

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

MIDP 3.0 overview. Copyright 2008 Aplix Corporation. All rights reserved.

COSC 6397 Big Data Analytics. Distributed File Systems (II) Edgar Gabriel Spring HDFS Basics

Socket Programming in Java

Crash Course in Java

Creating a Simple, Multithreaded Chat System with Java

Continuous Integration Part 2

File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files

public static void main(string[] args) { System.out.println("hello, world"); } }

DC60 JAVA AND WEB PROGRAMMING JUNE b. Explain the meaning of the following statement public static void main (string args [ ] )

How To Make A Game That Is Based On A Medieval Map (Georgie)

Remote Controlling of Home Appliances using Mobile Telephony

An Android-based Instant Message Application

Socket programming. Complement for the programming assignment INFO-0010

Mobile-PC Suite: Using Mobile Phone as Remote to Control PC Operations

Web Services in.net (1)

Mobile Application Development. MIDP & GUI Programmierung

Mobile App Sensor Documentation (English Version)

Contents. 9-1 Copyright (c) N. Afshartous

Bangla Text Input and Rendering Support for Short Message Service on Mobile Devices

The Software Engineering of Mobile Application Development

Lesson: All About Sockets

CS506 Web Design and Development Solved Online Quiz No. 01

Division of Informatics, University of Edinburgh

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

ResellerPlus - Bulk Http API Specification. (This Document gives details on how to send messages via the Bulk HTTP API for the RouteSms SMPP System)

CS 121 Intro to Programming:Java - Lecture 11 Announcements

Intel Retail Client Manager Audience Analytics

The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)

!"# $ %!&' # &! ())*!$

Quick Introduction to Java

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Manual. Programmer's Guide for Java API

Introduction to the Java Programming Language

5 HDFS - Hadoop Distributed System

gomobi Traffic Switching Guide Version 0.9, 28 September 2010

java Features Version April 19, 2013 by Thorsten Kracht

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

How To Write A Program For The Web In Java (Java)

Oracle Java SE Embedded

Java ME Clients for XML Web Services

Spring Design ScreenShare Service SDK Instructions

The Java Logging API and Lumberjack

MSDG Services Integration Document Draft Ver 1.2

String sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivepacket.getaddress(); int port = receivepacket.

Transcription:

! ""#

::. Contenuti della lezione $%&' % ('))')') *+ ') $ &,!!!$!-,.../- ' % + &

::. Le diverse edizioni di Java: J2EE,J2SE,J2ME!" # " $

::. Le diverse edizioni di Java: J2EE,J2SE,J2ME % & ' () * +, ( + -., / 0) * 1-

::. Profili e Configurazioni!"!# "! $%!& ' #( )"& % #( * + *+,-.../

::. Profili e Configurazioni!$/0&2 1 *2-, 1$34#,5(6-7,34 $34#,5(6-7,34. 63#,02 /'0&)"$%1&/' *$1 1 ')* 1

::. Profili e Configurazioni CLDC Mobile phones PDS. KVM (160k-512k) CDC Set-top boxes Personal video recorders. CVM (512k-2MB) Native Operating System

::. CDC vs. CLDC 0 0 '82 $01$/ $1$ $1$$01$ '82 ) 0 #()0

::. Configurazione CLDC (JSR 139)!! " #$%$&'()"* 0) * 2 %& # +

::. Configurazione CLDC (JSR 139), -,. / 01 01'4,'4, 01 9 01 01 01 01%!& ++23 (molte classi derivate da Java.lang.error non esistono) 45 6,

::. Configurazione CLDC (JSR 139) -. 0 #778 / 01 01 6*, ++23 4!,3 -: +')* $01$ '

::. Configurazione CLDC (JSR 139) /9 6:!

::. Configurazione CDC (JSR 218)! 3 $) ;$);1* 2') *",%& java.lang" + "#$! "%! 1- +; ++ +!< + ),

::. Configurazione CDC (JSR 218) + <-<=+. 2 0<=+ 6"<=+ 1 1 9 25(, 2 $ ;5 4 5(,?7+57@ *& 0<=+: 5(,7 + -=7 &' (" >)5, >! &' (" ;<=+:, 2-5(, ( )!!!

::. Configurazione CDC (JSR 218) / 20103 $*09 9 public static void main(string[] args) MainAppClass #*java MainAppClass

::. Configurazione CDC (JSR 218) /6632 = > )5 A,B! = C 8,! D7*0 ')* C 0')* *-$ + 0)/ <=+? -> 2.

::. Configurazione CDC (JSR 218) /@32 A 5(,,4/ +E -=7 F +!! (*)! 5 ;* 0; 6*,6*,

::. I profili: Foundation Profile (JSR 219) $1$ % & #,3 45(, 6: java.io, java.lang, java.lang.ref, java.lang.reflect, java.math, java.net, java.security, java.security.acl, java.security.cert, java.security.interfaces, java.security.spec, java.text, java.util, java.util.jar, java.util.zip, javax.microedition.io ('82 5$#!

::. I profili: Personal Basis Profile (JSR 217) $1$ %& #, -=7 #'B ; 6: java.awt, java.awt.color, java.awt.event, java.awt.image java.beans java.rmi, java.rmi.registry javax.microedition, javax.microedition.xlet.ixc java.applet G # 2 2 ;

::. I profili: Personal Profile (JSR 216) $1$ %&, -=7 '%<& '

::. I profili: Mobile Information Device (JSR 118) 2 2 +7 +6 2 (,+ + +G 2 D772+220+=702 = 7 0<2<+ $HIJK - <! + ++ +2*2+ +G

//*, /+ 2$1$$10$$1$AJA+$01$AA 1=! +0;;LM+=! $+0;-6*+32+ );= +G 0$ 2"! (, #!!! )- 5$$./ 0 *AA ' 23

//*, /+)B 2$1$$10$$1$AJA+$01$AA 1=! +0;;LM+=! $+0;-6*+32+ );= +G 0 -',7',7-37$-37 *AA$1$ * ')*$01$ 1*.!!2 5$%&! 3 +! 4) "!)!

//*, / 4 + 2$1$ 1=! $+0;;LM+0;-6* 0$0 $',7 5$5 *AA ' 23 2'4,'4,+') *1,')*1,+') *,')*, > ')* 5(6#!!!!7$.8

//*, / (, -(,. ) *$01$ AJ 10;+32+2+2<4 0$0 $',7-37 5$5 * ')* 1 ) * IJF LJ@B # 0' A8L@B6-* '4,

//*, / 4 + ) *$01$ AA 10;- ;LM+2<4 0$0 $',7% &+D 2-37 5$5 * ')*, 0')*+ : >

//*, / 4 + 2:,A C 2%:& 0 )* * 23, * 6 :

::. Application Models: MidLet, 0*0/ /!!! - 9 * 2: > + *0 0*0/ / %& 5$ 0*0> -$7,)

::. Ciclo di sviluppo di una MidLet,-H07/ : ' #* F '8*N $* 6?, F $01$ D* 6: F *0 + N +'-1 E* 2 F *0

::. Java Application Descriptor (JAD) $O+ O!O!,'-19'-6 +*,1 > +< > *,1 '-6!+ + '-1,'-1/ $: *,14 *,1) *,1) *,1 *,1'(60

::. Java Application Descriptor (JAD) MIDlet-Version: 1.0.2 MIDlet-Vendor: Totore Consulting MIDlet-Jar-URL: http://www.mobilab.unina.it/hello.jar MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.0 MIDlet-1: Demo1, /image/img1.png, org.mobilab.midlets.helloworld MIDlet-Jar-Size: 10819 MIDlet-Name: HelloWorld

::. Sviluppo MIDP: Elementi Base 3*0 javax.microedition.midlet.midlet, 9-*2++ *0 (*0 void startapp() void pauseapp() void destroyapp(boolean unconditional)

::. Application Models: MidLet import javax.microedition.midlet.*; *-! -*2F - *2< 09-*2 + public class BasicMIDlet extends MIDlet { public BasicMIDlet() { // constructor - don't do much here } protected void destroyapp(boolean unconditional) throws MIDletStateChangeException { // the system destroys the MIDlet } protected void pauseapp() { // the system pauses the MIDlet } } protected void startapp() throws MIDletStateChangeException { // the system activates the MIDlet }

::. Application Models: MidLet 1 3 9 getproperty 5 9!! " ( 6 *0resumeRequest 5"$':!!9 +! $!5!!" * *0notifyPaused 1*0notifyDestroyed

::. NetBeans ) " 0$110 5;!*;!',,*' 7! 1> 5F GFF1 ( ' '8*-3 5(' 4!(25 6768 (' 4!(5 669 ) * 4 + -. 4 + -. (60!www.netbeans.org

::. NetBeans /!(, 3 "! '!4 &- 0<.! "#! =! 1->?'! 7!* "#'@1-=#A

::. NetBeans Screen Designer 65 9 : : ; 6 =+ 9 H

::. NetBeans Flow Designer "

::. NetBeans Source Editor? < -. 3

::. NetBeans Configurazione Emulatore $ 9*9$1$ ($3 $1$$01$ - 9< 9!

::. NetBeans Esecuzione I5" 0$4&- 0<. 6 0$4&- 00 '73 1-B?8C! (D$#(

::. Applicazioni di rete con J2ME 0!1 2,0!1- ' % *.3+45+,'67-

::. Generic Connection Framework (GCF) H 4+ 2*2**2 B =# (*72 7$+(1+67+GG D77+D772+#7+G

::. Generic Connection Framework (GCF) H '8*!:,3 9 9,3 /! %5& 7!/ <303;+10032+109;3> 1;( $01$ AJ,5$#/ $1$+. '82'26AKP

::. Generic Connection Framework (GCF) J <9K 9,3! -E! #-, - 8 <7; 2* 2 $ B 2

::. Generic Connection Framework (GCF) + :! <+ 3 #! (! 9"!! = ; -=;.!!+

::. Generic Connection Framework (GCF) <+

::. Generic Connection Framework (GCF) + 6 Connection, DatagramConnection F,61 (1+7$ InputConnection+OutputConnection F,61 2 StreamConnection F $ ContentConnection F 2StreamConnection+ StreamConnectionNotifier ( Connector F#<,(60 (60

::. Generic Connection Framework (GCF) 3 H <9 L 4226 M)N 0 O 5:*I :

::. Generic Connection Framework (GCF) =; 26#$APCL8CKM scheme://user:password@host:port/url-path;parameters F,5$# F + 65 F!+ F #?14,: (60 F +?F % &,>

::. Generic Connection Framework (GCF) < -#FE. import java.io.*; import javax.microedition.midlet.*; import javax.microedition.io.*; import javax.microedition.lcdui.*; public class GCFConn extends MIDlet { private Display display; private String url = "http://wpage.unina.it/saorland/hellocms.txt"; public GCFConn() { display = Display.getDisplay(this); } public void startapp() { try { downloadpage(url); } catch(ioexception e) { alert = new Alert(message,e.toString(), null, AlertType.WARNING); alert.settimeout(alert.forever); display.setcurrent(alert); } } [CONTINUA...]

::. Generic Connection Framework (GCF) < -$FE. private void downloadpage(string url) throws IOException { StringBuffer b = new StringBuffer(); StringBuffer h = new StringBuffer(); String hf = ""; // not null InputStream is = null; HttpConnection c = null; TextBox t = null; try { long len = 0 ; int ch = 0; c = (HttpConnection)Connector.open(url); is = c.openinputstream(); // Fetch the HTTP Header for (int i = 0 ; hf!= null; i++) { hf = c.getheaderfieldkey(i); h.append(i+": "+hf); hf = c.getheaderfield(i); if (hf!= null && hf!= "") h.append("="+hf+"\n"); } [CONTINUA...]

::. Generic Connection Framework (GCF) < -DFE. [CONTINUA METODO downloadpage] len = c.getlength(); if ( len!= -1) { // Read exactly Content-Length bytes for (int i =0 ; i < len ; i++ ) if ((ch = is.read())!= -1) b.append((char) ch); } else { // Read till the connection is closed. while ((ch = is.read())!= -1) { len = is.available() ; b.append((char)ch); } } } [CONTINUA...]

::. Generic Connection Framework (GCF) < -EFE. [CONTINUA METODO downloadpage] // Dump file data to the device screen t = new TextBox("hello again...",h.tostring()+b.tostring(),2048,0); // Dump file data to ktoolbar System.out.println("Headers"); System.out.println(h.toString()); System.out.println("Body"); System.out.println(b.toString()); } finally { is.close(); c.close(); } display.setcurrent(t); } } public void pauseapp() {} public void destroyapp(boolean unconditional) {}

::. Java APIs for Bluetooth (JSR-82) -,+ B' 0 ' B '26L8/ 8 1) javax.bluetooth 4-,B 2) javax.obex -, %3N;& QBR

::. Java APIs for Bluetooth (JSR-82) ;M *IA8@63*6-* $ B,'8*$01$ 6: B 5-21<- 2 21< -6. 6#:<$3** -;91. 0 0$- -$6. B$$-).

::. Java APIs for Bluetooth (JSR-82) 6+;?%$ 6B 6 2 6#$3**+08$-3BH,3 5 #% <& : 3'4 -, 9')* @4,

::. Java APIs for Bluetooth (JSR-82) ) 0'B> M #* + : $* < D* ; E* ; &* ; '*

::. Java APIs for Bluetooth (JSR-82) + : :) H A :) M M A J -). + ( ::: 6+ ) ;?%$ -!!! : 6+A

::. Java APIs for Bluetooth (JSR-82) < 3 ;!!!!... // retrieve the local Bluetooth device object LocalDevice local = LocalDevice.getLocalDevice(); // retrieve the Bluetooth address and name of the local device String address = local.getbluetoothaddress(); String name = local.getfriendlyname();... ; : ::... // retrieve the device that is at the other end of the Bluetooth connection RemoteDevice remote = RemoteDevice.getRemoteDevice(Connection c); // retrieve the Bluetooth address and name of the remote device String remoteaddress = remote.getbluetoothaddress(); String remotename = local.getfriendlyname(true);...

::. Java APIs for Bluetooth (JSR-82) ;-#F$. + /J 0M ;DiscoveryAgent A DiscoveryListener DiscoveryAgent - startinquiry. 1 M devicediscovered A DiscoveryListener inquirycompleted DiscoveryListener DiscoveryAgent!! retrievedevices!! @ A +!! +!

::. Java APIs for Bluetooth (JSR-82) ;-$F$. 3,+3+0I=+;P... // retrieve the discovery agent DiscoveryAgent agent = local.getdiscoveryagent(); // place the device in inquiry mode boolean complete = agent.startinquiry();... ;3=63;1+2+61+2+,+012+... // retrieve the discovery agent DiscoveryAgent agent = local.getdiscoveryagent(); // return an array of pre-known devices RemoteDevice[] devices = agent.retrievedevices(discoveryagent.preknown); //usare CACHED per //risultati inquiries precedenti...

::. Java APIs for Bluetooth (JSR-82) ; J M + DiscoveryAgent /6+;?%$

::. Java APIs for Bluetooth (JSR-82) ; J ) #* $* "! -)). D* ; + / ) ; ))

::. Java APIs for Bluetooth (JSR-82) ) 0'26L8 $6F 0B 9 : 9 A *;; 8 2-6 < ;91 F 628C8B+ 08$- 1)3@ = BS

::. Java APIs for Bluetooth (JSR-82) 6 6 -#F$. ;91$6 3 -;?$D$. # ;91 G'7! ;91 = )QGD7;91-1#L 1D7. = Q ;91

::. Java APIs for Bluetooth (JSR-82) 6 6 -$F$. ; / =; * =; ) ; - N. 3=;/ btspp://102030405060740a1b1c1d1e100:5 Proto Address Port (porta COM)

::. Java APIs for Bluetooth (JSR-82) 36 6 -#F$.?... // service URL String ServiceURL = "btspp://localhost:10203040607040a1b1c1de100;name=spp Server1"; try { // create a server connection StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open(serviceURL); // accept client connections StreamConnection connection = notifier.acceptandopen(); // prepare to send/receive data byte buffer[] = new byte[100]; String msg = "hello there, client"; InputStream is = connection.openinputstream(); OutputStream os = connection.openoutputstream(); // send data to the client os.write(msg.getbytes()); // read data from client is.read(buffer); connection.close(); } catch(ioexception e) { e.printstacktrace(); }...

::. Java APIs for Bluetooth (JSR-82) 36 6 -$F$.?... // (assuming we have the service record) // use record to retrieve a connection URL String url = record.getconnectionurl( record.noauthenticate_noencrypt, false); // open a connection to the server StreamConnection connection = (StreamConnection) Connector.open(url); // Send/receive data try { byte buffer[] = new byte[100]; String msg = "hello there, server"; InputStream is = connection.openinputstream(); OutputStream os = connection.openoutputstream(); // read data from the server is.read(buffer); // send data to the server os.write(msg.getbytes); connection.close(); } catch(ioexception e) { e.printstacktrace(); }...