Java ME: CLDC и MIDP Борис Кварцхава

Slides:



Advertisements
Similar presentations
Bruce Scharlau, University of Aberdeen, 2010 Java ME Networking Mobile Computing Some slides from MobEduNet This covers HTTP in detail, and mentions other.
Advertisements

MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
J2ME Form Nesneleri Melih Sakarya. Form Nesnesi Form form= new Form("Giris"); display.setCurrent(form);
J2ME Melih Sakarya Java Teknolojileri Derneği. JVM JAVA Kullanılan yerler  Windows-Linux-Unix-Solaris  PDA lar  Smart Cardlar  Cep Telefonları  Appletler.
Jan Java I/O Yangjun Chen Dept. Business Computing University of Winnipeg.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Java 2D Training. Basic Tools Java SDK 1.4x Wireless Toolkit 2.x NetBeans IDE + mobility pack Global Code editor Text Comparer Tools Graphics Editor Sprite.
Socket Programming ENTERPRISE JAVA. 2 Content  Sockets  Streams  Threads  Readings.
1 Mobile Software Development Framework: TinyOS, J2ME 10/2/2012 Y. Richard Yang.
Department of Computer Science & Engineering
Writing Your First MIDlet Running JAVA on a Cell Phone Jon A. Batcheller January 27, 2004.
Introduction to Java 2 Micro Edition Mark Balbes, Ph.D. Senior Software Engineer Jeff Brown Senior Software Engineer.
Cosc 4755 Low-level GUI APIs. Low-Level API Composed of Canvas and Graphics classes – GameCanvas will be covered later on Canvas is an abstract class,
Developing an Application with J2ME Technology Scott Palmer, Nat Panchee, Judy Sullivan, Karen Thabet, Sten Westgard.
Cosc 4755 Mobile networking Overview and Stream, Socket, and Datagram.
Using Processing Stream. Predefined Streams System.in InputStream used to read bytes from the keyboard System.out PrintStream used to write bytes to the.
Overview of Java I/O. Stream A Program often needs to read/write information from/to outer source/destination. Outer source/destination can be : –A File.
JAVA ME PARALLELISM AND IMPLEMENTATIONS FOR EMBEDDED DEVICES Adam Stirtan.
Developing Software for Wireless Devices
PDA Programming Using J2ME Presenter :涂俊凱 Date : 2003/4/8.
Making Cell Phone Games An Overview Ray Ratelis Guild Software, Inc.
Developing J2ME Applications Mobile and Wireless Networks.
Cosc 4730 Phone Programming in Java An Introduction.
CS 225 Java Review. Java Applications A java application consists of one or more classes –Each class is in a separate file –Use the main class to start.
Java Platform, Micro Edition (J2ME)
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
J2ME Java for Mobile Environments Based on J2ME In A Nutshell, by Kim Topley, O’Reilly & Associates Inc., 2002, and Tetris by Alexei Patinov.
An Introduction to the Java ME Project Jens A Andersson.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 Using the KToolbar Rob Pooley
Platforms and tools for Web Services and Mobile Applications J2ME based Applications Bent Thomsen Aalborg University 3rd and 4th of June 2004.
1 Mobile Software Development Framework 4/14/2009 Richard Yang.
Michael Brockway Advanced Applications Development in Java J2ME -- Introduction l Introduction / Overview l Java 2 Micro Edition n CLDC n MIDP l Examples.
J2ME: M3G/11 Intro to J2ME. Prog. v Objectives: –to introduce M3G; –to start talking about "M3G Chapter 2. An Animated Model" u leave the floor,
Using J2ME to create Field Force Applications Chris Clark, MobileHWY, LLC.
1 OFDM, Mobile Software Development Framework 9/27/2012 Y. Richard Yang.
Mobile Applications and Java ME
Java Packages and Libraries M Taimoor Khan
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 lcdui Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 14 Various MIDlet examples Rob Pooley
Input/output Input in java is stream based.A stream represents sequence of bytes or characters. Stream provides an abstract view of I/O. Stream can be.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 15 IO Using http Rob Pooley
Saint Petersburg, 2011 Java Lecture Generics. Quiz ArrayList lst = new ArrayList(); Collection c = lst; lst.add("one"); lst.add(“two"); lst.add(“three");
Java 2 Micro Edition The Connected, Limited Device Configuration.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 8 CDC andJ2ME Rob Pooley
모바일 자바 프로그래밍 MIDP RMS Ps lab 오민경. MIDP RMS  RMS (Record Management System)  MIDP 에서 정의하는 영속성을 지닌 자체 데이터 저장 공간  Record Store 의 집합으로 구성된 아주 간단한 데이터베이스.
MIDP Programming Networking. Chapter Objectives The CLDC Streams Model Generic Connection Framework (GCF) Supported Protocols Creating a Connection Review.
Java 2 Platform, Micro Edition (J2ME)
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
Lab 2: J2ME: Java 2 Micro Edition (Writing Programs for Mobile Phones using Java) Luis F. G. Sarmenta draft 3/13/2008 MIT D-Lab ICT4D.
CSE403: MIDlets and Ant1 MIDlets and Ant April 3, 2003 Shane Cantrell Zach Crisman.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
Access to Remote Data ( ) Frank Ducrest.
CS202 Java Object Oriented Programming Input and Output Chengyu Sun California State University, Los Angeles.
The Java Platform Micro Edition Java ME
The Java IO System Different kinds of IO Different kinds of operations
CS434/534: Topics in Networked (Networking) Systems WSN/Mobile Systems Yang (Richard) Yang Computer Science Department Yale University 208A Watson
Java- I/O, SMS etc N Amanquah.
Java N Amanquah.
Mobile Software Development Framework: TinyOS, J2ME
Mobile Software Development Framework
By Jeff Heaton An Overview of J2ME By Jeff Heaton
J2ME Command Class.
Kjava Programming.
Session 10 J2ME Prof. Sridhar Iyer IIT Bombay
J2ME Java 2 Micro Edition Don Law.
Unit-2 Objects and Classes
Java for Mobile Devices
Files and Streams in Java
Presentation transcript:

Java ME: CLDC и MIDP Борис Кварцхава

CLDC: Пакеты: java.io — базовые интерфейсы и утилитные классы ввода-вывода Подмножество java.io в Java SE java.lang — фундаментальные классы Java Подмножество java.lang Java SE java.util — коллекции и утилитные классы для хранения дат и времени. Подмножество java.util Java SE javax.microedition.io - Generic Connection framework aka GCF. Ввод-вывод! Этих классов нет в JavaSE API!!!

Пакет java.lang Классы - обёртки примитивных типов (Boolean Byte Character Double Float Integer Long Short) - System — обёртка вокруг ОС - Math — математика - Thread - нити - String, StringBuffer — работа со строками - Исключения (AIOOBE, ILE, RE, NPE, итд) - Интерфейс Runnable

Пакет java.io - Два интерфейса: DataInput и DataOutput - Классы: Потоки - ByteArrayInputStream ByteArrayOutputStream DataInputStream DataOutputStream InputStream PrintStream OutputStream Чтецы и писатели (из потоков): Reader InputStreamReader Writer OutputStreamWriter - Исключения - EOFException InterruptedIOException IOException UnsupportedEncodingException UTFDataFormatException

Пакет java.util - Интерфейс Enumeration - Коллекции: Hashtable Stack Vector - Время и дата: Calendar Date TimeZone - Генератор случайных чисел: Random - Исключения EmptyStackException NoSuchElementException

Пакет javax.microedition.io - Generic Connection Framework (GCF) - Интерфейсы: Connection ContentConnection Datagram DatagramConnection InputConnection OutputConnection StreamConnection StreamConnectionNotifier - Класс Connector - Исключение ConnectionNotFoundException

Как открыть соединение? Просто:... try { Connection c = Connector.open(« } catch(ConnectionNotFoundException cnfe) { System.out.println(«http is not supported!»); } … HttpConnection httpc = (HttpConnection)c; … InputStream is = c.openInputStream(); int byteRead = is.read(); c.close();

MIDP 2.0 Пакеты: java.lang java.util javax.microedition.io javax.microedition.lcdui javax.microedition.lcdui.game javax.microedition.media javax.microedition.media.control javax.microedition.midlet javax.microedition.pki javax.microedition.rms Безопасность для приложений MIDP Спецификация OTA/Provisioning

Откроем javadoc: - Классы CLDC помечены, но не присутствуют в спецификации - OTA/Provisioning и безопасность присутствуют отдельно

Пакет javax.microedition.lcdui - Главный класс: Display, всё начинается с него Главный метод: Display.setCurrent(Displayable) - Displayable: «то, что может быть показано на дисплее» - Наследники Displayable: Alert Canvas Form List Screen и TextBox - В Form можно добавить Image-и и/или Item-ы (ChoiceGroup, CustomItem, DateField, Gauge, ImageItem, Spacer, StringItem, TextField)

Команды: - Создание Command(String label, int commandType, int priority) - Добавление: Item.addCommand(Command), Item.removeCommand(Command) Displayable.addCommand(Command), Displayable.removeCommand(Command) - Получение событий Displayable.setCommandListener(CommandListener l)

Интерфейс CommandListener - Создайте свою реализацию CommandListener: Метод commandAction(Command c, Displayable d) - Добавление: Displayable.setCommandListener(CommandListener l) Alert.setCommandListener(CommandListener l) - Узнавайте, из какой команды и Displayable пришло событие, через проверку аргументов!

Класс Canvas — анимация class Animation extends Canvas implements Runnable { // paint the current frame void paint(Graphics g) {... } Display display; // the display for the application void paint(Graphics g) {... } // paint the current frame void startAnimation() { // set up initial frame repaint(); display.callSerially(this); } // called after previous repaint is finished void run() { if ( /* there are more frames */ ) { // set up the next frame repaint(); display.callSerially(this); }

События от пальцев :-) В классе Canvas есть методы keyPressed(int kc) keyReleased(int kc) keyRepeated(int kc) pointerPressed(int x, int y) pointerDragged(int x, int y) pointerReleased(int x, int y) boolean hasPointerEvents() boolean hasPointerMotionEvents() boolean hasRepeatEvents()

Звук (ABB), пакет javax.microedition.media - Точное подмножество JSR 135 MMAPI - Класс Manager - Исключение MediaException - Интерфейсы: Control Controllable Player PlayerListener

Простейший пример:... try { Player p = Manager.createPlayer(" p.start(); } catch (MediaException pe) { } catch (IOException ioe) { }...

Дополнительная функциональность в плеерах: Пакет javax.microedition.media.control: Интерфейсы ToneControl и VolumeControl

Приложения — MIDlet-ы Пакет javax.microedition.midlet.MIDlet Класс MIDlet Исключение MIDletStateChangeException

Пример ============ HelloWorld.java ============================ import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet implements CommandListener { private Command exitCommand; private TextBox tbox; public HelloWorld() { exitCommand = new Command("Exit", Command.EXIT, 1); tbox = new TextBox("Hello world MIDlet", "Hello World!", 25, 0); tbox.addCommand(exitCommand); tbox.setCommandListener(this); } protected void startApp() { Display.getDisplay(this).setCurrent(tbox); } protected void pauseApp() {} protected void destroyApp(boolean bool) {} public void commandAction(Command cmd, Displayable disp) { if (cmd == exitCommand) { destroyApp(false); notifyDestroyed(); }

ВОПРОСЫ?