綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] 關於Android 4.3 藍芽4.0程式開發的幾個相關問題請教

[複製連結] 查看: 7971|回覆: 3|好評: 0
跳轉到指定樓層
樓主
x22819 | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2013-10-20 18:23

馬上加入Android 台灣中文網,立即免費下載應用遊戲。

您需要 登錄 才可以下載或查看,沒有帳號?註冊

x
我要開發一個Android 4.3的防丟器功能,目前功能可以搜尋、連線

1. 使用設定中的藍芽連接過的裝置可以利用getBondedDevices列出,但無法記憶透過我APP連線過的裝置,列出配對過的裝置程式如下,getBondedDevices是屬於API 18?? 可以用於藍芽4.0裝置的嗎?

Set<BluetoothDevice> setPairDevice = mBluetoothAdapter.getBondedDevices();
               
                if(setPairDevice.size() > 0) {
                        for(final BluetoothDevice device : setPairDevice) {
                                runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                                // TODO Auto-generated method stub
                                                mLeDeviceListAdapter.addDevice(device);
                                                mLeDeviceListAdapter.notifyDataSetChanged();
                                        }
                                });
                        }
                }


2.目前想要擷取連接後的藍芽裝置的訊號強度,將readRemoteRssi在GattCallback中呼叫,但使用readRemoteRssi與OnreadRemoteRssi時,在Log上看,回傳的值都是0。程式如下:

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status,
            int newState) {
        // TODO Auto-generated method stub
        String intentAction;
        if(newState == BluetoothProfile.STATE_CONNECTED) {
            intentAction = ACTION_GATT_CONNECTED;
            mConnectionState = STATE_CONNECTED;
            mBluetoothGatt.readRemoteRssi();
                .
                .
                .
                .
                .
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }

        public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
            final Intent rssiIntent = new Intent(BluetoothLeService.this, DeviceControl.class);
            rssiIntent.putExtra(DeviceControl.RSSI, rssi);
        }


        };//BluetoothGattCallback End




找尋很多資料  可是都不太適用,希望有人知道的可以教教我  

或是readRemoteRssi的正確用法???


謝謝大家!!!!
「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏1 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

沙發
Wen-Chin-Huang | 收聽TA | 只看該作者
發表於 2013-10-21 16:21
該不會是tiny finder~~XDD
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

板凳
 樓主| x22819 | 收聽TA | 只看該作者
發表於 2013-10-22 18:56
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

地板
Wen-Chin-Huang | 收聽TA | 只看該作者
發表於 2013-10-30 16:46
getBondedDevices 是 18的

參考一下兩篇因為我看不太懂你的問題~~XDD

http://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#readRemoteRssi()

http://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onReadRemoteRssi(android.bluetooth.BluetoothGatt,%20int,%20int)
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則