本文整理匯總了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;
}
}
}