當前位置: 首頁>>代碼示例>>Java>>正文


Java ScanResult.getDevice方法代碼示例

本文整理匯總了Java中android.bluetooth.le.ScanResult.getDevice方法的典型用法代碼示例。如果您正苦於以下問題:Java ScanResult.getDevice方法的具體用法?Java ScanResult.getDevice怎麽用?Java ScanResult.getDevice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.bluetooth.le.ScanResult的用法示例。


在下文中一共展示了ScanResult.getDevice方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBatchScanResults

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
public void onBatchScanResults(List<ScanResult> results) {
    CallsCounter.logCounter(context, "BluetoothLEScanCallback21.onBatchScanResults", "BluetoothLEScanCallback21.onBatchScanResults");

    boolean scanStarted = (BluetoothScanJob.getWaitForLEResults(context));

    if (scanStarted) {
        for (ScanResult result : results) {
            //PPApplication.logE("BluetoothLEScanCallback21", "onBatchScanResults - result=" + result.toString());

            BluetoothDevice device = result.getDevice();
            String btName = device.getName();
            PPApplication.logE("BluetoothLEScanCallback21", "onBatchScanResults - deviceName=" + btName);

            BluetoothDeviceData deviceData = new BluetoothDeviceData(btName, device.getAddress(),
                    BluetoothScanJob.getBluetoothType(device), false, 0);

            BluetoothScanJob.addLEScanResult(deviceData);
        }
    }
}
 
開發者ID:henrichg,項目名稱:PhoneProfilesPlus,代碼行數:21,代碼來源:BluetoothLEScanCallback21.java

示例2: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice device = result.getDevice();
    if ( device != null )
    {
        String msg = device.getName() + "\n" +"[RSSI : " + result.getRssi() + "dBm]" + device.getAddress();
        NLog.d( "onLeScan " + msg );

        /**
         * setting pen client control for ble
         */
            if(!temp.contains( device.getAddress() ))
            {
                NLog.d( "ACTION_FOUND onLeScan : " +device.getName() + " address : "+ device.getAddress()+", COD:" + device.getBluetoothClass());
                temp.add( device.getAddress());
                mNewDevicesArrayAdapter.add(msg);
            }
    }
}
 
開發者ID:NeoSmartpen,項目名稱:AndroidSDK2.0,代碼行數:21,代碼來源:DeviceListActivity.java

示例3: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
	super.onScanResult(callbackType, result);
	if (devices != null) {
		BluetoothDevice device = result.getDevice();				
		/*
		if ((device.getName() != null) && !devices.containsKey(device.getAddress())) {
			debug("New device detected " + device.getAddress() + " " + device.getName());
			if (device.getName().toUpperCase().contains("U2F")) {					
				devices.put(device.getAddress(), device);
			}
		}
		*/
		if (!devices.containsKey(device.getAddress())) {
			debug("New device detected " + device.getAddress() + "/" + (device.getName() != null ? device.getName() : ""));					
			devices.put(device.getAddress(), device);
		}				
	}
}
 
開發者ID:LedgerHQ,項目名稱:u2f-ble-test,代碼行數:20,代碼來源:MainActivity.java

示例4: convertBleDevice

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public BleDevice convertBleDevice(ScanResult scanResult) {
    if (scanResult == null) {
        throw new IllegalArgumentException("scanResult can not be Null!");
    }
    BluetoothDevice bluetoothDevice = scanResult.getDevice();
    int rssi = scanResult.getRssi();
    ScanRecord scanRecord = scanResult.getScanRecord();
    byte[] bytes = null;
    if (scanRecord != null)
        bytes = scanRecord.getBytes();
    long timestampNanos = scanResult.getTimestampNanos();
    return new BleDevice(bluetoothDevice, rssi, bytes, timestampNanos);
}
 
開發者ID:Jasonchenlijian,項目名稱:FastBle,代碼行數:15,代碼來源:BleManager.java

示例5: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    BluetoothDevice device = result.getDevice();
    Log.d(TAG, "scaning finished: "+device);
    if (device != null) {
        int toRemove = -1;
        for (int i = 0; i < beaconList.size(); i++) {
            if (device.getAddress().equals(beaconList.get(i).getMac())) {
                toRemove = i;
            }
        }

        if (toRemove != -1) {
            beaconList.remove(toRemove);

        }


    }
}
 
開發者ID:WillyShakes,項目名稱:UdooWtf,代碼行數:21,代碼來源:MainActivity.java

示例6: ScanResultCompat

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = result.getDevice();
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = result.getTimestampNanos();
}
 
開發者ID:joerogers,項目名稱:BluetoothCompat,代碼行數:8,代碼來源:ScanResultCompat.java

示例7: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result)
{
    BluetoothDevice device = result.getDevice();
    String mac_address = device.getAddress();

    boolean foundOurDevice = false;
    for (int i = 0; i < NUM_WORKOUTS; i++)
    {
        if (Gym.get(i).getMac_address().equals(mac_address) && Gym.get(i).getRSSI() == errorValue)
        {
            Gym.get(i).setRSSI(result.getRssi());
            Log.i(DEBUG, "Found one of our devices: " + mac_address);
            foundOurDevice = true;
            break;
        }
    }

    if (!foundOurDevice)
        Log.i(DEBUG, "Found another Bluetooth device.");
}
 
開發者ID:bbrown1867,項目名稱:Freeweight,代碼行數:22,代碼來源:BluetoothAndroid.java

示例8: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);

    BluetoothDevice device = result.getDevice();

    System.out.println("I see a bluetooth device: " + device.getAddress());

    List<ParcelUuid> uuids = result.getScanRecord().getServiceUuids();

    if(uuids != null) {
        for (ParcelUuid uuid :uuids) {
            System.out.println("Service UUID: " + uuid.getUuid());
        }
    }

    device.connectGatt(context, false, gattCallback);
}
 
開發者ID:tripzero,項目名稱:SuperPanel,代碼行數:19,代碼來源:Ble.java

示例9: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    super.onScanResult(callbackType, result);
    BluetoothDevice device = result.getDevice();
    String deviceAddress = device.getAddress();
    String deviceName = device.getName();

    String msg = "name=" + device.getName() + ", bondStatus="
            + device.getBondState() + ", address="
            + device.getAddress() + ", type" + device.getType();
    Log.d(TAG, msg);

    Pair<String, String> foundDevice = new Pair<>(deviceName, deviceAddress);
    if (!deviceList.contains(foundDevice)) {
        deviceList.add(foundDevice);
    }
}
 
開發者ID:cortinico,項目名稱:myo-emg-visualizer,代碼行數:18,代碼來源:MyoListFragment.java

示例10: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
public void onScanResult(int callbackType, ScanResult result) {
    CallsCounter.logCounter(context, "BluetoothLEScanCallback21.onScanResult", "BluetoothLEScanCallback21.onScanResult");

    boolean scanStarted = (BluetoothScanJob.getWaitForLEResults(context));

    if (scanStarted) {
        //PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - callbackType=" + callbackType);
        //PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - result=" + result.toString());

        BluetoothDevice device = result.getDevice();
        String btName = device.getName();
        PPApplication.logE("BluetoothLEScanCallback21", "onScanResult - deviceName=" + btName);

        BluetoothDeviceData deviceData = new BluetoothDeviceData(btName, device.getAddress(),
                BluetoothScanJob.getBluetoothType(device), false, 0);

        BluetoothScanJob.addLEScanResult(deviceData);
    }
}
 
開發者ID:henrichg,項目名稱:PhoneProfilesPlus,代碼行數:20,代碼來源:BluetoothLEScanCallback21.java

示例11: createCallback

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
private static android.bluetooth.le.ScanCallback createCallback(ScanCallback scanCallback) {
    return new android.bluetooth.le.ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {

            BluetoothDevice device = result.getDevice();
            int rssi = result.getRssi();
            byte[] scanRecord = (result.getScanRecord() != null ? result.getScanRecord().getBytes() : null);
            scanCallback.onDeviceFound(device, rssi, scanRecord);

            super.onScanResult(callbackType, result);
        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            super.onBatchScanResults(results);
        }

        @Override
        public void onScanFailed(int errorCode) {
            super.onScanFailed(errorCode);
        }
    };
}
 
開發者ID:devicehive,項目名稱:android-ble,代碼行數:25,代碼來源:BleScannerL.java

示例12: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@Override
public void onScanResult(int callbackType, ScanResult result) {
    boolean isDuplicate = false;

    //filter out duplicate entries if requested
    if(!rnbleModule.allowDuplicates){                
        for(String s : scannedDeviceAddresses){
            BluetoothDevice device = result.getDevice();
            String address = device.getAddress();

            if(s.equals(address)) {
               isDuplicate = true;
               break;
            }
        }
    }

    if(!isDuplicate){  
        scannedDeviceAddresses.add(result.getDevice().getAddress());
        super.onScanResult(callbackType, result);
        processScanResult(result);
    }
}
 
開發者ID:jacobrosenthal,項目名稱:react-native-ble,代碼行數:24,代碼來源:RNBLEModule.java

示例13: initCallbacks

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
private ScanCallback initCallbacks() {
    return new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            super.onScanResult(callbackType, result);

            if (result != null && result.getDevice() != null) {
                if (isAdded(result.getDevice())) {
                    // No add
                } else {
                    saveDevice(result.getDevice());
                }
            }

        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            super.onBatchScanResults(results);
        }

        @Override
        public void onScanFailed(int errorCode) {
            super.onScanFailed(errorCode);
        }
    };
}
 
開發者ID:jphacks,項目名稱:KB_1711,代碼行數:28,代碼來源:MainActivity.java

示例14: onScanResult

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
/**
 * Callback when a BLE advertisement has been found.
 *
 * @param callbackType Determines how this callback was triggered.
 * @param result       A Bluetooth LE scan result.
 */
@Override
public void onScanResult(int callbackType, final ScanResult result) {
    super.onScanResult(callbackType, result);

    // Get the ScanRecord and check if it is defined (is nullable)
    final ScanRecord scanRecord = result.getScanRecord();
    if (scanRecord != null) {
        // Check if the Service UUIDs are defined (is nullable) and contain the discovery
        // UUID
        final List<ParcelUuid> serviceUuids = scanRecord.getServiceUuids();
        if (serviceUuids != null && serviceUuids.contains(DISCOVERY_UUID)) {
            // We have found our device, so update the GUI, stop scanning and start
            // connecting
            final BluetoothDevice device = result.getDevice();

            // We'll make sure the GUI is updated on the UI thread
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // At this point we have the device address and RSSI, so update those
                    deviceAddressTextView.setText(device.getAddress());
                    rssiTextView.setText(getString(R.string.rssi, result.getRssi()));
                }
            });

            stopDiscovery();

            bluetoothGatt = device.connectGatt(
                    MainActivity.this,
                    // False here, as we want to directly connect to the device
                    false,
                    bluetoothGattCallback
            );
        }
    }
}
 
開發者ID:SPINremote,項目名稱:sdc-1-quickstart-android,代碼行數:43,代碼來源:MainActivity.java

示例15: ScanResultCompat

import android.bluetooth.le.ScanResult; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
ScanResultCompat(ScanResult result) {
    mDevice = new BluetoothLeDevice(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes(), System.currentTimeMillis());//result.getTimestampNanos()
    mScanRecord = new ScanRecordCompat(result.getScanRecord());
    mRssi = result.getRssi();
    mTimestampNanos = System.currentTimeMillis();//result.getTimestampNanos();
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:8,代碼來源:ScanResultCompat.java


注:本文中的android.bluetooth.le.ScanResult.getDevice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。