文件名称:BluetoothChat
介绍说明--下载内容均来自于网络,请自行研究使用
這一節的說明主要是針對 Linux 的環境,或者更嚴格的說是我還沒有發現 Blue Cove 以前的測試環境。現在 Windows XP SP2 之後已經支援藍芽的驅動程式,再加上 Blue Cove 以及藍芽設備,你就可以開始開發了。不過,我還是把以下的說明留下來當參考用。
兩部安裝了 Linux 的電腦,請確定這個版本的 Linux 內建支援 BlueZ。我們用的是 Fedora Core 1,你也可以參考 窮人的 Java Bluetooth 開發環境之建置 來建置你的開發環境。
依照 BlueZ 硬體相容清單 去採購你的藍芽裝置. 我用的是別人幫我買的 X-Micro 的 Bluetooth USB Dongle. 雖然這個設備並未出現在相容清單內,但是目前為止使用上都還蠻順利的。你可以在環境架好了以後,再去購買,如果發現不相容可以馬上退貨。
Linux 環境安裝有 J2SDK 1.4.x (or later) 以及 Rococo Software s Impronto Developer Kit for Linux.
安裝至少 bluez-libs 和 bluez-utils 套件。
請在兩部電腦上都利用以下指令來確定你的環境是正確的(# 為註解) -import java.io.*
import javax.bluetooth.*
public class LocalInfo
{
public static void main(String args[]) throws BluetoothStateException {
LocalDevice localdev = null
try {
localdev = LocalDevice.getLocalDevice()
} catch (BluetoothStateException e) {
System.out.println("ERROR: cannot access local device")
System.exit(1)
}
System.out.println("a local bluetooth device is found:")
System.out.println(" Name: "+ localdev.getFriendlyName())
System.out.println("Address: "+ localdev.getBluetoothAddress())
System.out.println("\nIts device classes are:")
DeviceClass devcla = localdev.getDeviceClass()
System.out.println(devcla.toString())
System.out.println("Service Class: "+ devcla.getServiceClasses())
System.out.println("Major Device Class: "+ devcla.getMajorDeviceClass())
System.out.println("Minor Device Class: "+ devcla.getMinorDeviceClass())
}
}
兩部安裝了 Linux 的電腦,請確定這個版本的 Linux 內建支援 BlueZ。我們用的是 Fedora Core 1,你也可以參考 窮人的 Java Bluetooth 開發環境之建置 來建置你的開發環境。
依照 BlueZ 硬體相容清單 去採購你的藍芽裝置. 我用的是別人幫我買的 X-Micro 的 Bluetooth USB Dongle. 雖然這個設備並未出現在相容清單內,但是目前為止使用上都還蠻順利的。你可以在環境架好了以後,再去購買,如果發現不相容可以馬上退貨。
Linux 環境安裝有 J2SDK 1.4.x (or later) 以及 Rococo Software s Impronto Developer Kit for Linux.
安裝至少 bluez-libs 和 bluez-utils 套件。
請在兩部電腦上都利用以下指令來確定你的環境是正確的(# 為註解) -import java.io.*
import javax.bluetooth.*
public class LocalInfo
{
public static void main(String args[]) throws BluetoothStateException {
LocalDevice localdev = null
try {
localdev = LocalDevice.getLocalDevice()
} catch (BluetoothStateException e) {
System.out.println("ERROR: cannot access local device")
System.exit(1)
}
System.out.println("a local bluetooth device is found:")
System.out.println(" Name: "+ localdev.getFriendlyName())
System.out.println("Address: "+ localdev.getBluetoothAddress())
System.out.println("\nIts device classes are:")
DeviceClass devcla = localdev.getDeviceClass()
System.out.println(devcla.toString())
System.out.println("Service Class: "+ devcla.getServiceClasses())
System.out.println("Major Device Class: "+ devcla.getMajorDeviceClass())
System.out.println("Minor Device Class: "+ devcla.getMinorDeviceClass())
}
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
BluetoothChat\.classpath
.............\.project
.............\AndroidManifest.xml
.............\bin\BluetoothChat.apk
.............\...\classes.dex
.............\...\.om\example\android\BluetoothChat\BluetoothChat$1.class
.............\...\...\.......\.......\.............\BluetoothChat$2.class
.............\...\...\.......\.......\.............\BluetoothChat$3.class
.............\...\...\.......\.......\.............\BluetoothChat.class
.............\...\...\.......\.......\.............\BluetoothChatService$AcceptThread.class
.............\...\...\.......\.......\.............\BluetoothChatService$ConnectedThread.class
.............\...\...\.......\.......\.............\BluetoothChatService$ConnectThread.class
.............\...\...\.......\.......\.............\BluetoothChatService.class
.............\...\...\.......\.......\.............\DeviceListActivity$1.class
.............\...\...\.......\.......\.............\DeviceListActivity$2.class
.............\...\...\.......\.......\.............\DeviceListActivity$3.class
.............\...\...\.......\.......\.............\DeviceListActivity.class
.............\...\...\.......\.......\.............\R$attr.class
.............\...\...\.......\.......\.............\R$drawable.class
.............\...\...\.......\.......\.............\R$id.class
.............\...\...\.......\.......\.............\R$layout.class
.............\...\...\.......\.......\.............\R$menu.class
.............\...\...\.......\.......\.............\R$string.class
.............\...\...\.......\.......\.............\R.class
.............\...\resources.ap_
.............\default.properties
.............\gen\com\example\android\BluetoothChat\R.java
.............\res\drawable\app_icon.png
.............\...\........-hdpi\app_icon.png
.............\...\layout\custom_title.xml
.............\...\......\device_list.xml
.............\...\......\device_name.xml
.............\...\......\main.xml
.............\...\......\message.xml
.............\...\menu\option_menu.xml
.............\...\values\strings.xml
.............\src\com\example\android\BluetoothChat\BluetoothChat.java
.............\...\...\.......\.......\.............\BluetoothChatService.java
.............\...\...\.......\.......\.............\DeviceListActivity.java
.............\bin\com\example\android\BluetoothChat
.............\gen\com\example\android\BluetoothChat
.............\src\com\example\android\BluetoothChat
.............\bin\com\example\android
.............\gen\com\example\android
.............\src\com\example\android
.............\bin\com\example
.............\gen\com\example
.............\src\com\example
.............\bin\com
.............\gen\com
.............\res\drawable
.............\...\drawable-hdpi
.............\...\drawable-ldpi
.............\...\drawable-mdpi
.............\...\layout
.............\...\menu
.............\...\values
.............\src\com
.............\assets
.............\bin
.............\gen
.............\res
.............\src
BluetoothChat
.............\.project
.............\AndroidManifest.xml
.............\bin\BluetoothChat.apk
.............\...\classes.dex
.............\...\.om\example\android\BluetoothChat\BluetoothChat$1.class
.............\...\...\.......\.......\.............\BluetoothChat$2.class
.............\...\...\.......\.......\.............\BluetoothChat$3.class
.............\...\...\.......\.......\.............\BluetoothChat.class
.............\...\...\.......\.......\.............\BluetoothChatService$AcceptThread.class
.............\...\...\.......\.......\.............\BluetoothChatService$ConnectedThread.class
.............\...\...\.......\.......\.............\BluetoothChatService$ConnectThread.class
.............\...\...\.......\.......\.............\BluetoothChatService.class
.............\...\...\.......\.......\.............\DeviceListActivity$1.class
.............\...\...\.......\.......\.............\DeviceListActivity$2.class
.............\...\...\.......\.......\.............\DeviceListActivity$3.class
.............\...\...\.......\.......\.............\DeviceListActivity.class
.............\...\...\.......\.......\.............\R$attr.class
.............\...\...\.......\.......\.............\R$drawable.class
.............\...\...\.......\.......\.............\R$id.class
.............\...\...\.......\.......\.............\R$layout.class
.............\...\...\.......\.......\.............\R$menu.class
.............\...\...\.......\.......\.............\R$string.class
.............\...\...\.......\.......\.............\R.class
.............\...\resources.ap_
.............\default.properties
.............\gen\com\example\android\BluetoothChat\R.java
.............\res\drawable\app_icon.png
.............\...\........-hdpi\app_icon.png
.............\...\layout\custom_title.xml
.............\...\......\device_list.xml
.............\...\......\device_name.xml
.............\...\......\main.xml
.............\...\......\message.xml
.............\...\menu\option_menu.xml
.............\...\values\strings.xml
.............\src\com\example\android\BluetoothChat\BluetoothChat.java
.............\...\...\.......\.......\.............\BluetoothChatService.java
.............\...\...\.......\.......\.............\DeviceListActivity.java
.............\bin\com\example\android\BluetoothChat
.............\gen\com\example\android\BluetoothChat
.............\src\com\example\android\BluetoothChat
.............\bin\com\example\android
.............\gen\com\example\android
.............\src\com\example\android
.............\bin\com\example
.............\gen\com\example
.............\src\com\example
.............\bin\com
.............\gen\com
.............\res\drawable
.............\...\drawable-hdpi
.............\...\drawable-ldpi
.............\...\drawable-mdpi
.............\...\layout
.............\...\menu
.............\...\values
.............\src\com
.............\assets
.............\bin
.............\gen
.............\res
.............\src
BluetoothChat