作者Gsus (肉元)
看板java
标题Re: [J2ME] 用手机抓取GPS接收器资料
时间Thu Jul 13 02:22:54 2006
※ 引述《PsMonkey (痞子军团团长)》之铭言:
: ==站内信件==
: ※ 引述《Gsus (肉元)》之铭言:
: : 好像不是耶...
: : 你这个我没看过
: 这位... 恩... 始作俑者...
: 那你要不要把你的开发环境讲清楚一点
: 单纯 po 这篇(还转出站外)
: 实在没意义也没任何帮助
嗯...开发环境...
J2ME对我而言颇陌生
开发环境..
我是用wireless toolkit
对於蓝芽传输
不太了解,我是看着书上的一些介绍+网站上的教学
应该说几乎都是网站上的教学啦
因为国内好像还没有J2ME的书里面提到蓝芽范例程式的
连线方式似乎是RFCOMM,
我目前只知道要跟蓝芽装置连线至少要有以下一些东西
LocalDevice, DiscoveryAgent, RemoteDevice, ServiceRecord
而其中我最需要的URL必须要先取得ServiceRecord,
接着call ServiceRecord[i].getConnectionURL();
ServiceRecord要怎麽取得...我看了教学网站的说明如下:
LocalDevice localdevice = LocalDevice.getLocalDevice();
DiscoveryAgent discoveryagent = localdevice.getDiscoveryAgent();
There are multiple ways to discover remote Bluetooth devices, but I'll discuss
one particular method. First,"your object must implement the
DiscoveryListener interface." This interface works like any listener, so it'll
notify you when an event occurs. In this case, you'll be notified when
Bluetooth devices are in the area. To start the discovery process, "call the
startInquiry() method on your DiscoveryAgent". This method is nonblocking, so
you're free to do other things while you wait for other Bluetooth devices to
be found.
When a Bluetooth device is found, the JVM calls the deviceDiscovered() method
of the class that implemented the DiscoveryListener interface. This method
passes you a RemoteDevice object that represents the device discovered by the
inquiry.
上文中""部份是我有疑问的:
1.我不懂什麽是DiscoveryListener...是我要implements然後覆盖一些abstract
method之类的吗??如果是话,DiscoveryListener 的 abstract method内容
要写些什麽呢??
2.startInquiry经过查询,我知道是DiscoveryAgent的method,但是却回传整数,
但上文中所说的似乎是最後要得到一个RemoteDevice的物件,这也是我的问题之一
Service discovery is just like device discovery - you use the DiscoveryAgent
to do the "discovering." The searchServices() method of the DiscoveryAgent
class allows you to search for services on a RemoteDevice. When services are
found, the servicesDiscovered() method will be called by the JVM if your
object implemented the DiscoveryListener interface. This callback method also
passes in a ServiceRecord object that pertains to the service you searched
for. With a ServiceRecord in hand, you can do plenty of things, but you would
most likely want to connect to the RemoteDevice where this ServiceRecord
originated:
String connectionURL = servRecord[i].getConnectionURL(0,false);
看完这段我一有些疑惑了~"~
因为searchServices()似乎是回传布林值,而非ServiceRecod,另外有一点就是,
这边似乎没用到上一段所取得的RemoteDevice,那我得RemoteDevice将来是要拿来
怎麽用呢?
对於蓝芽传输不是非常了解,我翻了一些原文书像是"Begining J2ME",
但是提到的不多,对於抓取URL更不用提...国内的书我还没看到有任何讲解
蓝芽传输方面的(没看到啦,至少我翻过王森写的、微型爪哇人、两三本J2ME
手机游戏开发的书,都找不到....> <)
所以来此发问希望获得帮忙
若有违反版规或是说明不清楚之处,烦请多多包含^^"
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.228.106.130
1F:推 PsMonkey:你已经触犯版规了... [茶] 07/13 10:25