亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Bluecove 的設置

Bluecove 的設置

繁星coding 2021-11-24 15:27:49
這是我與 bluecove 合作的第一個項目,我什至在開始之前就遇到了問題!這是我的代碼:import java.io.IOException;import java.util.ArrayList;import bluecove;/** * Class that discovers all bluetooth devices in the neighbourhood and   displays their name and bluetooth address. */public class BluetoothDeviceDiscovery implements DiscoveryListener {    // object used for waiting    private static Object lock = new Object();    // vector containing the devices discovered    public static ArrayList<RemoteDevice> devices;    public BluetoothDeviceDiscovery() {        devices = new ArrayList<RemoteDevice>();    }    // main method of the application    public static void main(String[] args) throws IOException {        //create an instance of this class        BluetoothDeviceDiscovery bluetoothDeviceDiscovery=new         BluetoothDeviceDiscovery();        //display local device address and name        LocalDevice localDevice = LocalDevice.getLocalDevice();        System.out.println("Address: " + localDevice.getBluetoothAddress());        System.out.println("Name: " + localDevice.getFriendlyName());        //find devices         DiscoveryAgent agent = localDevice.getDiscoveryAgent();        System.out.println("Starting device inquiry…");        agent.startInquiry(DiscoveryAgent.GIAC, bluetoothDeviceDiscovery);        try {            synchronized(lock) {                lock.wait();            }        }        catch (InterruptedException e) {            e.printStackTrace();        }        System.out.println("Device Inquiry Completed. ");        //print all devices in devices        int deviceCount=devices.size();        System.out.println(deviceCount);            }         }    }我在第 3 行(驚喜,驚喜)上收到一個錯誤,告訴我一個 ';' 預料之中。我知道我收到錯誤的真正原因是我沒有正確導入 bluecove。我下載了 bluecove jar,將其重命名并將文件添加到我的類路徑中,認為我現在可以在我的 java 項目中導入和使用 bluecove。我是否以錯誤的方式設置/導入 bluecove?我如何真正導入 bluecove 以便我可以在我的項目中使用藍牙?
查看完整描述

2 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

以防萬一有些不耐煩的人來這里快速復制和粘貼,這是我的進口清單:


import javax.bluetooth.BluetoothStateException;

import javax.bluetooth.DiscoveryAgent;

import javax.bluetooth.DiscoveryListener;

import javax.bluetooth.LocalDevice;

import javax.bluetooth.RemoteDevice;

import javax.bluetooth.UUID;


查看完整回答
反對 回復 2021-11-24
?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

前兩個import語句告知 Java您在代碼中引用的IOExceptionArrayList類的完整包路徑。

一旦您開始在代碼中使用 bluecove 類,您將需要添加一個或多個 import 語句,告訴 Java 這些類的完整包路徑。


查看完整回答
反對 回復 2021-11-24
  • 2 回答
  • 0 關注
  • 150 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號