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

Java PeerListListener类代码示例

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

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



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

示例1: onReceive

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	String action = intent.getAction();
	Logg.d(TAG, "received action " + action);
	// request list of peers
	wifi.getManager().requestPeers(
			wifi.getChannel(), new PeerListListener() {
		@Override
		public void onPeersAvailable(WifiP2pDeviceList peers) {
			// retreive list of devices
			devices.clear();
			for (WifiP2pDevice device : peers.getDeviceList()) {
				devices.add(device);
			}
			onChange();
			
			// if number of peers drops to zero
			if (devices.size() == 0) {
				// check again
				discover();
			}
		}
	});
}
 
开发者ID:wordsaretoys,项目名称:klammer,代码行数:25,代码来源:Peers.java


示例2: onReceive

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {

        // UI update to indicate wifi p2p status.
        int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
        if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
            // Wifi Direct mode is enabled
            listener.setIsWifiP2pEnabled(true);
        } else {
            listener.setIsWifiP2pEnabled(false);

        }
    } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
        // request available peers from the wifi p2p manager. This is an
        // asynchronous call and the calling activity is notified with a
        // callback on PeerListListener.onPeersAvailable()
        if (manager != null)
            manager.requestPeers(channel, (PeerListListener) listener);
    } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
        if (manager == null)
            return;

        NetworkInfo networkInfo = (NetworkInfo) intent
                .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);

        if (networkInfo.isConnected()) {
            // we are connected with the other device, request connection
            // info to find group owner IP
            manager.requestConnectionInfo(channel, (ConnectionInfoListener) listener);
        }
    } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
        listener.updateThisDevice((WifiP2pDevice) intent.getParcelableExtra(
                WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));
    }
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:38,代码来源:WiFiDirectBroadcastReceiver.java


示例3: onPeerListChanged

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
public void onPeerListChanged() {
	mManager.requestPeers(mChannel, new PeerListListener() {

		@Override
		public void onPeersAvailable(WifiP2pDeviceList peers) {
			Collection<WifiP2pDevice> peersCollection = peers.getDeviceList();
			updatePeerList(peersCollection);
		}
	});
}
 
开发者ID:deib-polimi,项目名称:SPF,代码行数:11,代码来源:WifiDirectMiddleware.java


示例4: updatePeers

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
@Override
public void updatePeers() {
    Logger.log(TAG, "Wi-Fi direct peers updating");
    mManager.requestPeers(mChannel, (PeerListListener)this.getSupportFragmentManager()
            .findFragmentById(R.id.frag_list));

}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:8,代码来源:CommCareWiFiDirectActivity.java


示例5: requestP2pPeers

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
public void requestP2pPeers(PeerListListener peerListListener) {
    LeBoxWifiDirectModel.getInstance().requestPeers(peerListListener);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:LeBoxNetworkManager.java


示例6: onReceive

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
@Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
            log("wifi direct changed state", false);
            // Determine if Wifi P2P mode is enabled or not, alert the Activity.
            int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);

            if (state != WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
                log("p2p not enabled", true);
            }
        } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
//        	log("peer list changed", false);

            if (p2pManager != null) {
                p2pManager.requestPeers(p2pChannel, new PeerListListener() {
                    @Override
                    public void onPeersAvailable(WifiP2pDeviceList peers) {
//						log("peer list changed", false);
                    }
                });
            }
        } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
            // Respond to new connection or disconnections
            log("connection changed", false);

            if (p2pManager == null) {
                return;
            }

            NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);

            if (networkInfo.isConnected()) {
                log("connected", false);

                // We are connected with the other device, request connection info to find group owner IP
                p2pManager.requestConnectionInfo(p2pChannel, new ConnectionInfoListener() {
                    @Override
                    public void onConnectionInfoAvailable(WifiP2pInfo info) {
                        InetAddress groupOwnerAddress = info.groupOwnerAddress;

                        if (info.groupFormed && info.isGroupOwner) {
                            wdManager.connected(groupOwnerAddress.getHostAddress(), true);
                            log("[connected] group owner with ip = " + groupOwnerAddress.getHostAddress() + " (me)", true);
                        } else if (info.groupFormed) {
                            wdManager.connected(groupOwnerAddress.getHostAddress(), false);
                            log("[connected] group owner ip = " + groupOwnerAddress.getHostAddress(), true);
                        }

                        wdManager.setConnected(true);
                    }
                });
            } else {
                // this is called also when the other peer refuses connection
                wdManager.setConnected(false);
                log("disconnected", true);
            }
        } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
            // This is called when the connectivity is lost
            // TODO unregister here any registered expressions with the remote
            wdManager.setConnected(false);
            wdManager.resetPeers();
            log("connectivity lost", true);
        }
    }
 
开发者ID:swandroid,项目名称:swan-sense-studio,代码行数:67,代码来源:WDBroadcastReceiver.java


示例7: onReceive

import android.net.wifi.p2p.WifiP2pManager.PeerListListener; //导入依赖的package包/类
@Override
	   public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
            // Determine if Wifi P2P mode is enabled or not, alert
            // the Activity.
        	
        	Log.d(TAG, "WIFI_P2P_STATE_CHANGED_ACTION");
            int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
            if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
                fetcher.setIsWifiP2pEnabled(true);
            } else {
                fetcher.setIsWifiP2pEnabled(false);
            }
        } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {

            // The peer list has changed!  We should probably do something about
            // that.
        	
            // request available peers from the wifi p2p manager. This is an
            // asynchronous call and the calling activity is notified with a
            // callback on PeerListListener.onPeersAvailable()
            if (manager != null) {
                manager.requestPeers(channel, (PeerListListener)fetcher);
            }
            Log.d(TAG, "WIFI_P2P_PEERS_CHANGED_ACTION");
            
            

        } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {

            // Connection state changed!  We should probably do something about
            // that.
        	Log.d(TAG, "WIFI_P2P_CONNECTION_CHANGED_ACTION");
            if (manager == null) {
                return;
            }

            NetworkInfo networkInfo = (NetworkInfo) intent
                    .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);

            if (networkInfo.isConnected()) {

                // We are connected with the other device, request connection
                // info to find group owner IP

                manager.requestConnectionInfo(channel, fetcher);
            }

        } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
//            DeviceListFragment fragment = (DeviceListFragment) activity.getFragmentManager()
//                    .findFragmentById(R.id.frag_list);
//            fragment.updateThisDevice((WifiP2pDevice) intent.getParcelableExtra(
//                    WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));

        } 
    }
 
开发者ID:lzq8272587,项目名称:ShareVideo,代码行数:58,代码来源:WiFiDirectBroadcastReceiver.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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