本文我们首先介绍在移动设备上进行java开发的基本原理.doc
还剩
16页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,很抱歉,此页已超出免费预览范围啦!
如果喜欢就下载吧,价低环保!
内容要点:
{ }// ignore showInfo("客户端输入:" + inputString + ",已成功响应!");} /*** 输出响应* @param outputData* @param conn */ private void sendOutputData (String outputData, StreamConnection conn) { try{ DataOutputStream }}/** * 从 StreamConnection 读取输入* @param conn * @return*/private String readInputString (StreamConnection conn) { String inputString = null;try {DataInputStream dis = conn.openDataInputStream();inputStprocessorThread = new Thread(this);processorThread.start();}public void run() { while (!isClosed){synchronized (this){ if (queue.size() == 0){ try { //阻塞,直到有新客户连接 wait();}catch (InterruptedException eisClosed = false; this.setString(null);new Thread(this).start();}public void cancelService(){ isClosed = true;showInfo("服务终止"); this.removeCommand(com_cancel); this.addCommand(com_pub);} /* * (non-Javif (!localDevice.setDiscoverable (DiscoveryAgent.GIAC)) {showInfo("无法设置设备发现模式 "); return;}// prepare a URL to create a notifier StringBuffer url = new StringBuffer("btspp://");// indicate this is a seimport javax.microedition.io.Connector;import javax.microedition.io.StreamConnection; import javax.microedition.io. StreamConnectionNotifier;import javax.microedition.lcdui.Command;import javax.microesynchronized (this) {notify(); } } /*** 回调方法*/public void servicesDiscovered (int transID, ServiceRecord[] servRecord){ for (int i = 0; i < servRecord.length; i++){ records.addElement(servRecord[i]); } catch (BluetoothStateException e) {continue; } }try { //阻塞,由 serviceSearchCompleted()回调方法在所有设备都搜索完的情况下唤醒 wait();}catch (InterruptedException e1) {e1.printStackTrace();}showInfo("服务搜索完毕, 共找到 "+record
发表评论
暂无评论,赶快抢占沙发吧。