本文整理匯總了Java中it.gerdavax.easybluetooth.LocalDevice類的典型用法代碼示例。如果您正苦於以下問題:Java LocalDevice類的具體用法?Java LocalDevice怎麽用?Java LocalDevice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LocalDevice類屬於it.gerdavax.easybluetooth包,在下文中一共展示了LocalDevice類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActivityResult
import it.gerdavax.easybluetooth.LocalDevice; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case REQUEST_DISCOVERY:
if (resultCode == RESULT_OK){
String address = data.getStringExtra(DeviceDiscovery.ADDRESS_EXTRA);
// add only if device is not already in the list
if (!devices.deviceEntries.contains(new BTDevice(address))){
db.open();
db.createDevice(new BTDevice(LocalDevice.getInstance().getRemoteForAddr(address)));
devices.deviceEntries = db.fetchAllDevices();
db.close();
devices.notifyDataSetChanged();
}
else {
Logger.d(TAG, "Duplicate entry: device already added");
Toast.makeText(this, "Selected device is already in your list", Toast.LENGTH_SHORT).show();
}
}
break;
}
}
示例2: connect
import it.gerdavax.easybluetooth.LocalDevice; //導入依賴的package包/類
protected void connect(final String address){
if (address == null) return;
localDevice = LocalDevice.getInstance();
localDevice.init(this, new ReadyListener() {
@Override
public void ready() {
RemoteDevice device = localDevice.getRemoteForAddr(address);
localDevice.destroy();
new ConnectThread(device).start();
}
});
}
示例3: onCreate
import it.gerdavax.easybluetooth.LocalDevice; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Discovered Devices");
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.discovered_devices_list);
adapter = new DeviceAdapter();
setListAdapter(adapter);
setProgressBarIndeterminateVisibility(true);
localDevice = LocalDevice.getInstance();
}