本文整理汇总了Java中com.orbotix.common.DiscoveryException类的典型用法代码示例。如果您正苦于以下问题:Java DiscoveryException类的具体用法?Java DiscoveryException怎么用?Java DiscoveryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryException类属于com.orbotix.common包,在下文中一共展示了DiscoveryException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startDiscovery
import com.orbotix.common.DiscoveryException; //导入依赖的package包/类
public void startDiscovery(@NonNull Context context)
{
//If the DiscoveryAgent is not already looking for robots, start discovery.
if(!DualStackDiscoveryAgent.getInstance().isDiscovering()) {
try {
DualStackDiscoveryAgent.getInstance().startDiscovery(context);
Log.d(TAG, "Start discovery");
} catch (DiscoveryException e) {
Log.e(TAG, "DiscoveryException: " + e.getMessage());
}
}
}
示例2: startDiscovery
import com.orbotix.common.DiscoveryException; //导入依赖的package包/类
private void startDiscovery() {
try {
_discoveryAgent = DiscoveryAgentLE.getInstance();
// You first need to set up so that the discovery agent will notify you when it finds robots.
// To do this, you need to implement the DiscoveryAgentEventListener interface (or declare
// it anonymously) and then register it on the discovery agent with DiscoveryAgent#addDiscoveryListener()
_discoveryAgent.addDiscoveryListener(_discoveryAgentEventListener);
// Second, you need to make sure that you are notified when a robot changes state. To do this,
// implement RobotChangedStateListener (or declare it anonymously) and use
// DiscoveryAgent#addRobotStateListener()
_discoveryAgent.addRobotStateListener(_robotStateListener);
// Creating a new radio descriptor to be able to connect to the BB8 robots
RobotRadioDescriptor robotRadioDescriptor = new RobotRadioDescriptor();
robotRadioDescriptor.setNamePrefixes(new String[]{"BB-"});
_discoveryAgent.setRadioDescriptor(robotRadioDescriptor);
// Then to start looking for a BB8, you use DiscoveryAgent#startDiscovery()
// You do need to handle the discovery exception. This can occur in cases where the user has
// Bluetooth off, or when the discovery cannot be started for some other reason.
_discoveryAgent.startDiscovery(this);
} catch (DiscoveryException e) {
Log.e("Sphero", "Discovery Error: " + e);
e.printStackTrace();
}
}
示例3: startDiscovery
import com.orbotix.common.DiscoveryException; //导入依赖的package包/类
/**
* 検知を開始する.
*
* @param context コンテキストオブジェクト.
*/
public synchronized void startDiscovery(final Context context) {
try {
if (!discoveryAgent.isDiscovering()) {
discoveryAgent.startDiscovery(context);
}
} catch (DiscoveryException e) {
e.printStackTrace();
}
}