本文整理汇总了Java中android.bluetooth.BluetoothDevice.fetchUuidsWithSdp方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothDevice.fetchUuidsWithSdp方法的具体用法?Java BluetoothDevice.fetchUuidsWithSdp怎么用?Java BluetoothDevice.fetchUuidsWithSdp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.bluetooth.BluetoothDevice
的用法示例。
在下文中一共展示了BluetoothDevice.fetchUuidsWithSdp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
device.fetchUuidsWithSdp();
if (bluetoothDevicesAdapter.getPosition(device) == -1) {
// -1 is returned when the item is not in the adapter
bluetoothDevicesAdapter.add(device);
bluetoothDevicesAdapter.notifyDataSetChanged();
}
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
toolbarProgressCircle.setVisibility(View.INVISIBLE);
setStatus("None");
} else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
switch (state) {
case BluetoothAdapter.STATE_OFF:
Snackbar.make(coordinatorLayout, "Bluetooth turned off", Snackbar.LENGTH_INDEFINITE)
.setAction("Turn on", new View.OnClickListener() {
@Override public void onClick(View v) {
enableBluetooth();
}
}).show();
break;
}
}
}