android.net.wifi.p2p.WifiP2pManager.ChannelListener Java Examples

The following examples show how to use android.net.wifi.p2p.WifiP2pManager.ChannelListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WiFiP2PManager.java    From nfcspy with GNU General Public License v3.0 5 votes vote down vote up
void init(Context ctx, ChannelListener lsn) {
	wifip2p = (WifiP2pManager) ctx.getSystemService(WIFI_P2P_SERVICE);

	channel = wifip2p.initialize(ctx, ctx.getMainLooper(), lsn);

	if (wifip2p != null && channel != null) {
		isWifiP2pEnabled = true;
		status = STA_P2P_INITED;
	} else {
		isWifiP2pEnabled = false;
		status = STA_P2P_UNINIT;
	}
}
 
Example #2
Source File: WifiController.java    From gilgamesh with GNU General Public License v3.0 5 votes vote down vote up
public void init (GilgaService service)
{
 mService = service;

     mWifiManager = (WifiP2pManager) mService.getSystemService(Context.WIFI_P2P_SERVICE);
     
     mWifiChannel = mWifiManager.initialize(mService, mService.getMainLooper(), new ChannelListener()
     {

@Override
public void onChannelDisconnected() {
	Log.d(GilgaService.TAG,"wifi p2p disconnected");
}
     	
     });
     
     WifiP2pDnsSdServiceRequest serviceRequest = WifiP2pDnsSdServiceRequest.newInstance();
     mWifiManager.addServiceRequest(mWifiChannel,
             serviceRequest,
             new ActionListener() {
                 @Override
                 public void onSuccess() {
                     // Success!
 	            	Log.d(TAG,"SUCCESS: added service request wifi name service");

                 }

                 @Override
                 public void onFailure(int code) {
                     // Command failed.  Check for P2P_UNSUPPORTED, ERROR, or BUSY
                 	Log.d(TAG,"FAILURED: added service request wifi name service: " + code);
                 }
             });
     
}