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