本文整理匯總了Java中com.peak.salut.Callbacks.SalutDeviceCallback類的典型用法代碼示例。如果您正苦於以下問題:Java SalutDeviceCallback類的具體用法?Java SalutDeviceCallback怎麽用?Java SalutDeviceCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SalutDeviceCallback類屬於com.peak.salut.Callbacks包,在下文中一共展示了SalutDeviceCallback類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startNetworkService
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void startNetworkService(@Nullable SalutDeviceCallback onDeviceRegisteredWithHost, @Nullable SalutCallback onSuccess, @Nullable SalutCallback onFailure)
{
//In order to have a service that you create be seen, you must also actively look for other services. This is an Android bug.
//For more information, read here. https://code.google.com/p/android/issues/detail?id=37425
//We do not need to setup DNS responders.
registeredClients = new ArrayList<>();
this.onDeviceRegisteredWithHost = onDeviceRegisteredWithHost;
if(!receiverRegistered)
{
dataReceiver.context.registerReceiver(receiver, intentFilter);
receiverRegistered = true;
}
createService(onSuccess, onFailure);
discoverNetworkServices(deviceNotSupported);
}
示例2: startNetService
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void startNetService() {
mSalut.startNetworkService(new SalutDeviceCallback() {
@Override
public void call(SalutDevice salutDevice) {
Log.i(TAG, "startNetworkService, onWifiDeviceConnected, device:" + salutDevice.deviceName);
mSendToDevice = salutDevice;
mCallback.onWifiDeviceConnected(salutDevice);
}
}, new SalutCallback() {
@Override
public void call() {
Log.i(TAG, "startNetworkService, init success");
}
}, new SalutCallback() {
@Override
public void call() {
Log.i(TAG, "startNetworkService, init failed");
mCallback.onStartWifiServiceFailed();
}
});
}
示例3: startNetworkService
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void startNetworkService(@Nullable SalutDeviceCallback onDeviceRegisteredWithHost, @Nullable SalutCallback onSuccess, @Nullable SalutCallback onFailure) {
//In order to have a service that you create be seen, you must also actively look for other services. This is an Android bug.
//For more information, read here. https://code.google.com/p/android/issues/detail?id=37425
//We do not need to setup DNS responders.
registeredClients = new ArrayList<>();
this.onDeviceRegisteredWithHost = onDeviceRegisteredWithHost;
if (!receiverRegistered) {
dataReceiver.context.registerReceiver(receiver, intentFilter);
receiverRegistered = true;
}
createService(onSuccess, onFailure);
discoverNetworkServices(deviceNotSupported);
}
示例4: discoverNetworkServices
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void discoverNetworkServices(SalutDeviceCallback onDeviceFound, boolean callContinously)
{
if(!respondersAlreadySet)
{
setupDNSRespondersWithDevice(onDeviceFound, callContinously);
}
discoverNetworkServices(deviceNotSupported);
}
示例5: discoverNetworkServices
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void discoverNetworkServices(SalutDeviceCallback onDeviceFound, boolean callContinously) {
if (!respondersAlreadySet) {
setupDNSRespondersWithDevice(onDeviceFound, callContinously);
}
discoverNetworkServices(deviceNotSupported);
}
示例6: setupDNSRespondersWithDevice
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
private void setupDNSRespondersWithDevice(final SalutDeviceCallback onDeviceFound, final boolean callContinously)
{
/*Here, we register a listener for when services are actually found. The WiFi P2P specification notes that we need two types of
*listeners, one for a DNS service and one for a TXT record. The DNS service listener is invoked whenever a service is found, regardless
*of whether or not it is yours. To that determine if it is, we must compare our service name with the service name. If it is our service,
* we simply log.*/
WifiP2pManager.DnsSdServiceResponseListener serviceListener = new WifiP2pManager.DnsSdServiceResponseListener() {
@Override
public void onDnsSdServiceAvailable(String instanceName, String serviceNameAndTP, WifiP2pDevice sourceDevice) {
Log.d(TAG, "Found " + instanceName + " " + serviceNameAndTP);
}
};
/*The TXT record contains specific information about a service and it's listener can also be invoked regardless of the device. Here, we
*double check if the device is ours, and then we go ahead and pull that specific information from it and put it into an Map. The function
*that was passed in early is also called.*/
WifiP2pManager.DnsSdTxtRecordListener txtRecordListener = new WifiP2pManager.DnsSdTxtRecordListener() {
@Override
public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String, String> record, WifiP2pDevice device) {
if(!foundDevices.isEmpty())
{
for(SalutDevice found : foundDevices)
{
if(found.deviceName.equals(device.deviceName))
{
return;
}
}
}
if(record.containsValue(thisDevice.serviceName))
{
SalutDevice foundDevice = new SalutDevice(device, record);
foundDevices.add(foundDevice);
if(callContinously)
{
onDeviceFound.call(foundDevice);
}
else
{
if(!firstDeviceAlreadyFound)
{
onDeviceFound.call(foundDevice);
firstDeviceAlreadyFound = true;
}
}
}
}
};
manager.setDnsSdResponseListeners(channel, serviceListener, txtRecordListener);
respondersAlreadySet = true;
}
示例7: setOnDeviceUnregisteredCallback
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
public void setOnDeviceUnregisteredCallback(SalutDeviceCallback callback) {
onDeviceUnregistered = callback;
}
示例8: setupDNSRespondersWithDevice
import com.peak.salut.Callbacks.SalutDeviceCallback; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setupDNSRespondersWithDevice(final SalutDeviceCallback onDeviceFound, final boolean callContinously) {
/*Here, we register a listener for when services are actually found. The WiFi P2P specification notes that we need two types of
*listeners, one for a DNS service and one for a TXT record. The DNS service listener is invoked whenever a service is found, regardless
*of whether or not it is yours. To that determine if it is, we must compare our service name with the service name. If it is our service,
* we simply log.*/
WifiP2pManager.DnsSdServiceResponseListener serviceListener = new WifiP2pManager.DnsSdServiceResponseListener() {
@Override
public void onDnsSdServiceAvailable(String instanceName, String serviceNameAndTP, WifiP2pDevice sourceDevice) {
Log.d(TAG, "Found " + instanceName + " " + serviceNameAndTP);
}
};
/*The TXT record contains specific information about a service and it's listener can also be invoked regardless of the device. Here, we
*double check if the device is ours, and then we go ahead and pull that specific information from it and put it into an Map. The function
*that was passed in early is also called.*/
WifiP2pManager.DnsSdTxtRecordListener txtRecordListener = new WifiP2pManager.DnsSdTxtRecordListener() {
@Override
public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String, String> record, WifiP2pDevice device) {
if (!foundDevices.isEmpty()) {
for (SalutDevice found : foundDevices) {
if (found.deviceName.equals(device.deviceName)) {
return;
}
}
}
if (record.containsValue(thisDevice.serviceName)) {
SalutDevice foundDevice = new SalutDevice(device, record);
foundDevices.add(foundDevice);
if (callContinously) {
onDeviceFound.call(foundDevice);
} else {
if (!firstDeviceAlreadyFound) {
onDeviceFound.call(foundDevice);
firstDeviceAlreadyFound = true;
}
}
}
}
};
manager.setDnsSdResponseListeners(channel, serviceListener, txtRecordListener);
respondersAlreadySet = true;
}