Главная » Просмотр файлов » Programming Java 2 Micro Edition for Symbian OS 2004

Programming Java 2 Micro Edition for Symbian OS 2004 (779882), страница 39

Файл №779882 Programming Java 2 Micro Edition for Symbian OS 2004 (Symbian Books) 39 страницаProgramming Java 2 Micro Edition for Symbian OS 2004 (779882) страница 392018-01-10СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 39)

This is performed bythe run() method:public void run() {while (listening) {synchronized(this) {while (listening && messageWaiting == 0 ) {try {wait();} catch (InterruptedException ie) {// Handle interruption}}if (messageWaiting != 0) {receiveMessage();messageWaiting--;198MIDP 2.0 AND THE JTWI}}}}This processes incoming messages in a while loop. When thereare no messages waiting the thread is paused. When awoken by anotification from the handleMessage() method, the thread checksthat there is a message waiting and if so processes it by calling thereceiveMessage() method.Functionality for sending messages is encapsulated in the Sender class:package com.symbian.devnet.chatmidlet;import javax.microedition.io.*;import javax.microedition.lcdui.*;import javax.wireless.messaging.*;import java.io.IOException;// Sends an SMS messagepublic class Sender implements Runnable {private String smsReceiverPort;private String message;private String phoneNumber;public Sender(String smsReceiverPort) {this.smsReceiverPort = smsReceiverPort;}public void run() {String address = "sms://" + phoneNumber + ":" +smsReceiverPort;MessageConnection smsconn = null;try {smsconn = (MessageConnection)Connector.open(address);TextMessage txtmessage = (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);txtmessage.setPayloadText(message);smsconn.send(txtmessage);}catch (Exception e) {e.printStackTrace();}if (smsconn != null) {try {smsconn.close();}catch (IOException ioe) {ioe.printStackTrace();}}}public void connectAndSend(String message, String phoneNumber) {this.message = message;this.phoneNumber = phoneNumber;OPTIONAL J2ME APIS IN THE JTWI199Thread t = new Thread(this);t.start();}}The connectAndSend() method takes a message and a phonenumber and creates a new Thread to send the message.

The actualsending is performed by the run() method which opens a connection,sends the message and then closes the connection.The application descriptor for the ChatMIDlet is listed below.MIDlet-1: SMS Chat, , com.symbian.devnet.chatmidlet.ChatMIDletMIDlet-Data-Size: 0MIDlet-Description: This midlet demonstrates SMS chattingMIDlet-Jar-Size: 6476MIDlet-Jar-URL: SMSChat.jarMIDlet-Name: SMS ChatMIDlet-Push-1: sms://:1234, com.symbian.devnet.chatmidlet.ChatMIDlet, *MIDlet-Vendor: Symbian Ltd.MIDlet-Version: 2.0MicroEdition-Configuration: CLDC-1.0MicroEdition-Profile: MIDP-2.0Note that the MIDlet-push-1 entry (shown below) is required toregister a push registry connection:MIDlet-Push-1: sms://:1234, com.symbian.devnet.chatmidlet.ChatMIDlet, *Screenshots of the ChatMIDlet running on a Nokia 6600 are shown inFigure 3.29.

The full source code and JAR and JAD files for the ChatMIDletcan be downloaded from the Symbian website at www.symbian.com/books.Figure 3.29 The SMS ChatMIDlet running on a Nokia 6600.200MIDP 2.0 AND THE JTWI3.4.4.6 WMA and the MIDP 2.0 Security ModelA signed MIDlet suite that contains MIDlets which open and use SMS connections must explicitly request the following permissions as appropriatein its MIDlet-Permissions attribute:• javax.microedition.io.Connector.sms – needed to openan SMS connection• javax.wireless.messaging.sms.send – needed to send anSMS• javax.wireless.messaging.sms.receive – needed to receive an SMSMIDlet-Permissions: javax.microedition.io.Connector.sms,javax.wireless.messaging.sms.sendor:MIDlet-Permissions: javax.microedition.io.Connector.sms,javax.wireless.messaging.sms.send,javax.wireless.messaging.sms.receiveIf the protection domain to which the signed MIDlet suite would bebound grants, or potentially grants, the requested permissions, the MIDletsuite can be installed and the MIDlets it contains will be able to open SMSconnections and send and receive SMS messages, either automaticallyor with explicit user permission, depending upon the security policyin effect.Whether MIDlets in untrusted MIDlet suites can access the WMAdepends on the security policy relating to the untrusted domain inforce on the device.

On the Nokia 6600 and Sony Ericsson P900/P908,MIDlets in untrusted MIDlet suites can access the Messaging functiongroup APIs with User permission. On both devices, the User permissionto access the Messaging function group is set to oneshot (and cannotbe changed by the user, except to deny permission to that MIDlet suitealtogether on the Nokia 6600). In line with the Recommended SecurityPolicy for GSM/UMTS Compliant Devices addendum to the MIDP 2.0specification and the JTWI Security Policy for GSM/UMTS CompliantDevices a Messaging function group permission of oneshot requiresexplicit user permission to send an SMS message, but allows blanketpermission (permission is granted until the MIDlet suite is uninstalled orthe user changes the function group permission) to receive SMS messages.The security policy in effect on the Sony Ericsson P900/P908 forMIDlets in MIDlet suites bound to the trusted protection domain is thesame as that for untrusted MIDlet suites detailed above.

At the time ofMIDP 2.0 AND SYMBIAN OS PHONES201writing, the available firmware version (3.42.1) on the Nokia 6600 didnot support the trusted protection domain (although this will be rectifiedin a future release).3.4.4.7 WMA on Symbian OS PhonesThe first implementation of the Wireless Messaging API on SymbianOS shipped as part of Nokia’s Series 60 v1.x platform.

This WMAimplementation supplemented the MIDP 1.0 environment available onthis platform. The first phone to support this implementation of the WMAwas the Nokia 3650.More recently, a MIDP 2.0-compatible version of the WMA shippedas part of Symbian OS Version 7.0s which forms the basis for Nokia’sSeries 60 v2.0 platform. The first mobile phone employing this platform,and therefore supporting WMA in conjunction with the push registrytechnology, was the Nokia 6600.Symbian also back-ported its WMA implementation compatible withMIDP 2.0 to the UIQ 2.1 reference design based on Symbian OS Version7.0.

The first device released using this platform was the Sony EricssonP900/P908.Note that Symbian’s implementation of the WMA currently does notsupport receiving CBS.3.5 MIDP 2.0 and Symbian OS PhonesAt the time of writing, two MIDP 2.0 phones based on Symbian OShave been released: the Nokia 6600 and Sony Ericsson P900/P908. Bothphones implement the mandatory APIs and the minimum configurationrequired by the JTWI.The Nokia 6600 (Figure 3.30) is a Series 60 Version 2.0 phone basedon Symbian OS Version 7.0s.

It runs the CLDC 1.0 HI (Monty) VM and,in addition to MIDP 2.0, includes the Wireless Messaging, Mobile MediaAPIs and also the Java Bluetooth APIs (which are not currently part of theJTWI and will be discussed in Chapter 4).The Sony Ericsson P900/P908 (Figure 3.31) is based on Symbian OSVersion 7.0 running UIQ 2.1 reference design. Symbian back-ported theCLDC 1.0 HI (Monty) VM, MIDP 2.0, the Wireless Messaging and Bluetooth APIs to the UIQ platform. An interesting feature of the P900/P908is that it allows the user to install firmware upgrades downloaded fromSony Ericsson’s website via a PC. It is therefore easy for users to ensurethey are running the latest available firmware, including the latest bugfixes to the Java implementation.Future MIDP 2.0-enabled phones in the pipeline include the Nokia6620, 7700, BenQ P30, Panasonic X700 and Motorola A1000.202MIDP 2.0 AND THE JTWIFigure 3.30Nokia 6600 phone.Figure 3.31 The Sony Ericsson P900 phone.3.6 SummaryIn this chapter we have discussed the JTWI and its component APIswith particular reference to their implementation on Symbian OS-basedphones.

First we briefly looked at the CLDC 1.0 and its various manifestations on Symbian OS. We then embarked on an in-depth discussionof MIDP 2.0 and its new features. Finally, we moved on to discuss theoptional APIs required by the JTWI, namely the Wireless Messaging andSUMMARY203Mobile Media APIs. Throughout the chapter the emphasis has been onproviding code examples that have been tested on real Symbian OS-basedMIDP 2.0 phones.In the next chapter we will look at another optional API, the JavaAPI for Bluetooth Wireless Technology, that is supported by the latestgeneration of Symbian OS phones, but which does not currently fallunder the JTWI.4Java APIs for Bluetooth WirelessTechnologyIn the last chapter we considered MIDP 2.0 and the optional APIs thatform part of the current release (Release 1) of the Java Technology forthe Wireless Industry initiative (JTWI).

In this chapter we will consider anoptional API that is also part of Symbian’s current J2ME offering, but isnot yet part of the JTWI: the Java API for Bluetooth Wireless Technology(JSR 82).4.1 Introduction to BluetoothBluetooth is an important emerging standard for wireless communicationbetween small devices such as mobile phones.

The original researchon Bluetooth was performed by Ericsson and the name derives fromthe tenth century Danish King Harald Blätand who united Denmark andNorway. Ericsson decided to make Bluetooth an open standard by invitingother industry leaders to participate in the establishment of the BluetoothSpecial Interest Group (SIG) in 1997. Today the Bluetooth SIG has over2000 members.Bluetooth is a short-range radio-based protocol operating in the2.4 GHz band of the RF spectrum.

Характеристики

Тип файла
PDF-файл
Размер
5,73 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6358
Авторов
на СтудИзбе
311
Средний доход
с одного платного файла
Обучение Подробнее