本文整理匯總了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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();
}
示例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.");
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
};
}
示例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);
}
}
示例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);
}
};
}
示例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
);
}
}
}
示例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();
}