当前位置: 首页>>代码示例>>Java>>正文


Java NsdServiceInfo.setServiceType方法代码示例

本文整理汇总了Java中android.net.nsd.NsdServiceInfo.setServiceType方法的典型用法代码示例。如果您正苦于以下问题:Java NsdServiceInfo.setServiceType方法的具体用法?Java NsdServiceInfo.setServiceType怎么用?Java NsdServiceInfo.setServiceType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.net.nsd.NsdServiceInfo的用法示例。


在下文中一共展示了NsdServiceInfo.setServiceType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
private int registerService(Context context) throws java.io.IOException {

        int port = findOpenSocket();

        // Create the NsdServiceInfo object, and populate it.
        NsdServiceInfo serviceInfo  = new NsdServiceInfo();

        // The name is subject to change based on conflicts
        // with other services advertised on the same network.
        serviceInfo.setServiceName(SERVICE_NAME_DEFAULT);
        serviceInfo.setServiceType(SERVICE_TYPE);
        serviceInfo.setPort(port);

        mNsdManager = (NsdManager)context.getSystemService(Context.NSD_SERVICE);

        if (mRegistrationListener == null)
            initializeRegistrationListener();

        mNsdManager.registerService(
                serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);

        return port;
    }
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:24,代码来源:NSDSender.java

示例2: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(final int port, final String serviceName, final String serviceType, final Map<String, String> attributes, final EventCallback callback) {
    Log.d(LOGTAG, "registerService: " + serviceName + "." + serviceType + ":" + port);
    synchronized (this) {
        if (mStartCallback != null) {
            throw new RuntimeException("Previous operation is not finished");
        }
        mStartCallback = callback;
    }

    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(serviceName);
    serviceInfo.setServiceType(serviceType);
    setAttributes(serviceInfo, attributes);
    nsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, this);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:17,代码来源:MulticastDNSManager.java

示例3: onCreate

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
@Override
public void onCreate() {
	httpService = this;
	Log.d(TAG, "My Service Created");
	try {
		server = new NanoHTTPDReceiver( //
				0, //
				new File("/"), //
				getApplicationContext() //
		);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	Log.d(TAG, "using port " + server.getLocalPort());
	NsdServiceInfo nsi = new NsdServiceInfo();
	nsi.setPort(server.getLocalPort());
	nsi.setServiceName("MultiShare");
	nsi.setServiceType("_http._tcp.");
	mNsdManager = (NsdManager) getSystemService(Context.NSD_SERVICE);
	mNsdManager.registerService(nsi, NsdManager.PROTOCOL_DNS_SD, this);
}
 
开发者ID:CmoaToto,项目名称:MultiShare,代码行数:23,代码来源:HttpServiceReceiver.java

示例4: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    // Create the NsdServiceInfo object, and populate it.
    NsdServiceInfo serviceInfo  = new NsdServiceInfo();

    // The name is subject to change based on conflicts
    // with other services advertised on the same network.
    serviceInfo.setServiceName(SERVICE_NAME);
    serviceInfo.setServiceType(SERVICE_TYPE);
    serviceInfo.setPort(port);

    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
 
开发者ID:holgi-s,项目名称:RangeThings,代码行数:14,代码来源:NsdHelper.java

示例5: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    tearDown();  // Cancel any previous registration request
    initializeRegistrationListener();
    NsdServiceInfo serviceInfo  = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);

    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);

}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:13,代码来源:NsdHelper.java

示例6: getServiceInfo

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
private NsdServiceInfo getServiceInfo(String name, String type, int localPort) {
    final NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setServiceName(name);
    serviceInfo.setServiceType(type);
    serviceInfo.setPort(localPort);
    return serviceInfo;
}
 
开发者ID:zendesk,项目名称:Suas-Android,代码行数:8,代码来源:NetworkSocketServer.java

示例7: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    tearDown();  // Cancel any previous registration request
    initializeRegistrationListener();
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);
    Log.v(TAG, Build.MANUFACTURER + " registering service: " + port);
    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
 
开发者ID:ekalyvio,项目名称:CowBit,代码行数:12,代码来源:NsdHelper.java

示例8: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    tearDown();  // Cancel any previous registration request
    initializeRegistrationListener();
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    mServiceName = NsdChatActivity.mServiceName;
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);
    Toast.makeText(mContext, "Service registered at port: " + port,Toast.LENGTH_SHORT).show();
    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);

}
 
开发者ID:suchoX,项目名称:Simplify,代码行数:14,代码来源:NsdHelper.java

示例9: toServiceInfo

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public NsdServiceInfo toServiceInfo() {
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setServiceType(SERVICE_TYPE);
    serviceInfo.setServiceName(mName);
    //serviceInfo.setAttribute(UUID, mUuid);
    serviceInfo.setPort(mPort);
    return serviceInfo;
}
 
开发者ID:nitroshare,项目名称:nitroshare-android,代码行数:9,代码来源:Device.java

示例10: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
/**
 * Register new service with given serivce name, type and port.
 *
 * @param desiredServiceName Desired service name. If the name already exists in network it will be change to something like 'AppChat (1)'.
 * @param serviceType        Service type.
 * @param port               Service port.
 */
public void registerService(String desiredServiceName, String serviceType, int port) {
    if (port == 0) return;

    mRegisteredServiceInfo = new NsdServiceInfo();
    mRegisteredServiceInfo.setServiceName(desiredServiceName);
    mRegisteredServiceInfo.setServiceType(serviceType);
    mRegisteredServiceInfo.setPort(port);

    mRegistrationListener = new NsdListenerRegistration(this);
    mNsdManager.registerService(mRegisteredServiceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
 
开发者ID:rafakob,项目名称:NsdHelper,代码行数:19,代码来源:NsdHelper.java

示例11: resolveService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
/**
 * Resolve service host and port.
 *
 * @param nsdService Service to be resolved.
 */
public void resolveService(NsdService nsdService) {
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setServiceName(nsdService.getName());
    serviceInfo.setServiceType(nsdService.getType());
    mResolveQueue.enqueue(serviceInfo);
}
 
开发者ID:rafakob,项目名称:NsdHelper,代码行数:12,代码来源:NsdHelper.java

示例12: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    tearDown();  // Cancel any previous registration request
    initializeRegistrationListener();
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);
    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}
 
开发者ID:MycroftAI,项目名称:Mycroft-Android,代码行数:11,代码来源:NetworkAutoDiscoveryUtil.java

示例13: resolveService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void resolveService(final String serviceName, final String serviceType, final EventCallback callback) {
    synchronized (this) {
        if (mCallback != null) {
            throw new RuntimeException("Previous operation is not finished");
        }
        mCallback = callback;
    }

    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setServiceName(serviceName);
    serviceInfo.setServiceType(serviceType);
    nsdManager.resolveService(serviceInfo, this);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:14,代码来源:MulticastDNSManager.java

示例14: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port) {
    NsdServiceInfo serviceInfo  = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);
    
    mNsdManager.registerService(
            serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
    
}
 
开发者ID:ArianJM,项目名称:you2peer,代码行数:11,代码来源:NsdHelper.java

示例15: registerService

import android.net.nsd.NsdServiceInfo; //导入方法依赖的package包/类
public void registerService(int port)
{
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);

    mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);

}
 
开发者ID:gaozh1986,项目名称:NsdChat,代码行数:11,代码来源:NsdHelper.java


注:本文中的android.net.nsd.NsdServiceInfo.setServiceType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。