• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DnsSdTxtRecordListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener的典型用法代码示例。如果您正苦于以下问题:Java DnsSdTxtRecordListener类的具体用法?Java DnsSdTxtRecordListener怎么用?Java DnsSdTxtRecordListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DnsSdTxtRecordListener类属于android.net.wifi.p2p.WifiP2pManager包,在下文中一共展示了DnsSdTxtRecordListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupDnsSdResponseListeners

import android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener; //导入依赖的package包/类
private void setupDnsSdResponseListeners(final DnsSdResponseListener listener) {
	
	/*
        * Register listeners for DNS-SD services. These are callbacks invoked
        * by the system when a service is actually discovered.
        */
	manager.setDnsSdResponseListeners(channel, 
			new DnsSdServiceResponseListener() {

		public void onDnsSdServiceAvailable(String instanceName,
				String registrationType, WifiP2pDevice srcDevice) {

			listener.onServiceAvailable(instanceName, registrationType, srcDevice);
		}
	}, new DnsSdTxtRecordListener() {

		public void onDnsSdTxtRecordAvailable(
				String fullDomainName, Map<String, String> record,
				WifiP2pDevice device) {

			listener.onTxtRecordAvailable(fullDomainName, record, device);
		}
	});
}
 
开发者ID:alvarollmenezes,项目名称:servicediscoverypg,代码行数:25,代码来源:WifiDirectManager.java


示例2: initialiseDnsTxtRecordListener

import android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener; //导入依赖的package包/类
private void initialiseDnsTxtRecordListener() {
    mDnsTxtRecordListener = new DnsSdTxtRecordListener() {

        @Override
        public void onDnsSdTxtRecordAvailable(String fullDomainName,
                Map<String, String> txtRecordMap, WifiP2pDevice srcDevice) {

            if (fullDomainName.contains(SERVICE_INSTANCE)) {

                WifiP2pConfig config = new WifiP2pConfig();
                config.deviceAddress = srcDevice.deviceAddress;
                config.groupOwnerIntent = 0;
                config.wps.setup = WpsInfo.PBC;

                mP2PManager.connect(mChannel, config, null);
            }

        }
    };
}
 
开发者ID:lolletsoc,项目名称:dissertation-project,代码行数:21,代码来源:WifiDirectSdHelper.java


示例3: launchServiceListner

import android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener; //导入依赖的package包/类
private void launchServiceListner(){
	Log.d(TAG, "Launching ServiceListner");
	manager.setDnsSdResponseListeners(channel,
			new DnsSdServiceResponseListener() {
			@Override
			public void onDnsSdServiceAvailable(String instanceName, String registrationType,WifiP2pDevice srcDevice) {
				Log.d(TAG, "ServiceAvailable " + instanceName);
				// A service has been discovered. check if this is the service we are searching for
		        if (instanceName.equalsIgnoreCase(SERVER_SERVICE_INSTANCE)) {
		        		//store the data in a service instance
		        		WifiClientP2pService p2pservice = new WifiClientP2pService();	//class to store service object
		                p2pservice.setDevice(srcDevice);
		                p2pservice.setInstanceName(instanceName);
		                p2pservice.setServiceRegistrationType(registrationType);
		                Log.d("WifisrvListner", "WifiService: "+ p2pservice.getInstanceName()+" from: "+p2pservice.getDevice());
		                Log.d("WifisrvListner","deviceAddress: "+p2pservice.getDevice().deviceAddress);
		                Log.d("WifisrvListner","deviceName: "+p2pservice.getDevice().deviceName);
		                /***auto device list***/
		                Log.d("WifisrvListner","adding device in list ");
		                addDevice(p2pservice.getDevice().deviceAddress, p2pservice);		//add device to the MAP1
		                /***auto device list***/
		                //connectP2p();								//connect to the device running server service
		        }
			}
		    }, new DnsSdTxtRecordListener() {
                @Override
            	public void onDnsSdTxtRecordAvailable(String fullDomain, Map<String, String> record, WifiP2pDevice device) {
                    Log.d("WifiTxtListner", "DnsSdTxtRecord available -"+device.deviceAddress);
                    Log.d("WifiTxtListner", "DnsSdTxtRecord String -"+record.get(TXTRECORD_SERVER_ANDROIDID));    
	                /***auto device list***/
                    if(record.get(TXTRECORD_SERVER_ANDROIDID) != null){
                    		addDeviceName(device.deviceAddress, record.get(TXTRECORD_SERVER_ANDROIDID)); //add device to the MAP2
                    }
	                /***auto device list***/

                }
		    });   
}
 
开发者ID:pranay22,项目名称:Audio-based-probing-of-the-environment,代码行数:39,代码来源:WifiClient.java


示例4: discoverWifiService

import android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener; //导入依赖的package包/类
private void discoverWifiService() {
    DnsSdTxtRecordListener txtListener = new DnsSdTxtRecordListener() {
        @Override
        /* Callback includes:
         * fullDomain: full domain name: e.g "printer._ipp._tcp.local."
         * record: TXT record dta as a map of key/value pairs.
         * device: The device running the advertised service.
         */

        public void onDnsSdTxtRecordAvailable(String fullDomain, Map record, WifiP2pDevice device) {
                
                String status = (String)record.get("status");
                
                Log.d(TAG,"got status from wifi DNS: " + device.deviceAddress + " (" + fullDomain + ") " + status);
                mService.processInboundMessage(device.deviceAddress,status,false);
            }
        
        };
    
        DnsSdServiceResponseListener servListener = new DnsSdServiceResponseListener() {
            @Override
            public void onDnsSdServiceAvailable(String instanceName, String registrationType,
                    WifiP2pDevice resourceType) {
            	Log.d(TAG,"SD service available!");
            }
        };
        
        mWifiManager.setDnsSdResponseListeners(mWifiChannel, servListener, txtListener);
        
        mWifiManager.discoverServices(mWifiChannel, new ActionListener() {

            @Override
            public void onSuccess() {
                // Success!
            	Log.d(TAG, "discover services!");
            }

            @Override
            public void onFailure(int code) {
                // Command failed.  Check for P2P_UNSUPPORTED, ERROR, or BUSY
                if (code == WifiP2pManager.P2P_UNSUPPORTED) {
                    Log.d(TAG, "P2P isn't supported on this device.");
                    mWifiEnabled = false;
                }
            }
        });

}
 
开发者ID:n8fr8,项目名称:gilgamesh,代码行数:49,代码来源:WifiController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResultSet类代码示例发布时间:2022-05-22
下一篇:
Java PKCS10类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap