本文整理汇总了Java中android.net.nsd.NsdManager.ResolveListener方法的典型用法代码示例。如果您正苦于以下问题:Java NsdManager.ResolveListener方法的具体用法?Java NsdManager.ResolveListener怎么用?Java NsdManager.ResolveListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.nsd.NsdManager
的用法示例。
在下文中一共展示了NsdManager.ResolveListener方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.e(TAG, "Resolve Succeeded. " + serviceInfo);
if (serviceInfo.getServiceName().equals(mServiceName)) {
Log.d(TAG, "Same IP.");
return;
}
mService = serviceInfo;
}
};
}
示例2: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "Resolve failed " + errorCode);
mService = null;
callCallback(CallbackTypeEnum.ResolveFailed);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.v(TAG, "Resolve Succeeded. " + serviceInfo);
if (serviceInfo.getServiceName().equals(mServiceName)) {
// Log.d(TAG, "Same IP.");
// return;
}
mService = serviceInfo;
callCallback(CallbackTypeEnum.ServiceResolved);
}
};
}
示例3: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.e(TAG, "Resolve Succeeded. " + serviceInfo);
if (serviceInfo.getServiceName().equals(mServiceName)) {
Log.d(TAG, "Same IP.");
return;
}
mService = serviceInfo;
}
};
}
示例4: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
private void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.d(TAG, "Resolve failed");
}
@Override
public void onServiceResolved(final NsdServiceInfo serviceInfo) {
Log.d(TAG, "Service resolved :" + serviceInfo);
final String hostName = serviceInfo.getHost().getHostName();
final int port = serviceInfo.getPort();
final String serviceName = serviceInfo.getServiceName();
handler.post(new Runnable() {
@Override
public void run() {
serviceDiscoveryListener.onBonjourServiceDiscovered(hostName, port, serviceName);
}
});
}
};
}
示例5: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
private void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(Constants.TAG, "Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
mServiceInfo = serviceInfo;
int port = mServiceInfo.getPort();
InetAddress host = mServiceInfo.getHost();
String address = host.getHostAddress();
Log.d(Constants.TAG, "Resolved address = " + address);
ServerInfo service = new ServerInfo(address, port);
mServers.add(service);
}
};
}
示例6: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Toast.makeText(mContext, "Resolve failed",Toast.LENGTH_SHORT).show();
Log.e(TAG, "Resolve failed" + errorCode);
}
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.d(TAG, "Resolve Succeeded. " + serviceInfo);
Toast.makeText(mContext, "Resolve succeeded",Toast.LENGTH_SHORT).show();
if (serviceInfo.getServiceName().equals(mServiceName)) {
Log.d(TAG, "Same IP.");
return;
}
mService = serviceInfo;
setConnected(true);
}
};
}
示例7: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener()
{
mResolveListener = new NsdManager.ResolveListener()
{
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode)
{
Log.e(TAG, "Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo)
{
Log.e(TAG, "Resolve Succeeded. " + serviceInfo);
if (serviceInfo.getServiceName().equals(mServiceName))
{
Log.d(TAG, "Same IP.");
return;
}
mService = serviceInfo;
}
};
}
示例8: initializeResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.e(TAG, "Resolve Succeeded. " + serviceInfo);
mService = serviceInfo;
/*
if (serviceInfo.getServiceName().equals(mServiceName)) {
Log.d(TAG, "Same IP.");
return;
}
mService = serviceInfo;
*/
}
};
}
示例9: initResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
private void initResolveListener() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Timber.e("Resolve failed" + errorCode);
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Timber.e("Resolve Succeeded. " + serviceInfo);
if(onNsdChangeListener != null) {
onNsdChangeListener.onServiceResolved(serviceInfo);
} else {
Timber.e("no OnNsdChangeListener set");
}
}
};
}
示例10: initializeNsd
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public void initializeNsd() {
mResolveListener = new NsdManager.ResolveListener() {
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
Log.e(TAG, "Resolve failed" + errorCode);
Toast.makeText(mContext, "Resolve failed" + errorCode, Toast.LENGTH_SHORT).show();
}
@Override
public void onServiceResolved(NsdServiceInfo serviceInfo) {
Log.d(TAG, "Resolve Succeeded. " + serviceInfo);
Toast.makeText(mContext, "Resolve Succeeded. " + serviceInfo, Toast.LENGTH_SHORT).show();
if (serviceInfo.getServiceName().equals(mServiceName) && flag) {
Log.d(TAG, "Same IP.");
Toast.makeText(mContext, "Same IP.", Toast.LENGTH_SHORT).show();
return;
}
mService = serviceInfo;
final NsdChatActivity ac = (NsdChatActivity)mContext;
ac.runOnUiThread(new Runnable() {
@Override
public void run() {
//show the join button
ac.setVisibilityButton(true);
}
});
//ac.setVisibilityButton(true);
}
};
}
示例11: getResolveListener
import android.net.nsd.NsdManager; //导入方法依赖的package包/类
public NsdManager.ResolveListener getResolveListener() { return resolveListener;}