@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { if(progressDialog != null && progressDialog.isShowing()) progressDialog.dismiss(); this.info = info; this.getView().setVisibility(View.VISIBLE); TextView view = (TextView)mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text)+ ((info.isGroupOwner == true)?getResources().getString(R.string.yes): getResources().getString(R.string.no))); view = (TextView)mContentView.findViewById(R.id.device_info); view.setText("Group Owner IP - "+info.groupOwnerAddress.getHostAddress()); if(info.groupFormed && info.isGroupOwner){ new FileServerAsnycTask(getActivity(), mContentView.findViewById(R.id.status_text)).execute(); }else if(info.groupFormed){ mContentView.findViewById(R.id.btn_start_client).setVisibility(View.VISIBLE); ((TextView)mContentView.findViewById(R.id.status_text)).setText(getResources() .getString(R.string.client_text)); } mContentView.findViewById(R.id.btn_connect).setVisibility(View.GONE); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } this.info = info; this.getView().setVisibility(View.VISIBLE); // The owner IP is now known. TextView view = (TextView) mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo struct. view = (TextView) mContentView.findViewById(R.id.device_info); view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. // hide the connect button }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { Log.e("ConnectionInfoListener",info.toString()); // InetAddress from WifiP2pInfo struct. InetAddress groupOwnerAddress = info.groupOwnerAddress; // After the group negotiation, we can determine the group owner. if (info.groupFormed && info.isGroupOwner) { // Do whatever tasks are specific to the group owner. // One common case is creating a server thread and accepting // incoming connections. new Server(groupOwnerAddress).start(); } else if (info.groupFormed) { // The other device acts as the client. In this case, // you'll want to create a client thread that connects to the group // owner. new Client(groupOwnerAddress).start(); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { // InetAddress from WifiP2pInfo struct. try { InetAddress groupOwnerAddress = InetAddress.getByName(info.groupOwnerAddress.getHostAddress()); } catch (Exception e) { } // After the group negotiation, we can determine the group owner. if (info.groupFormed && info.isGroupOwner) { // Do whatever tasks are specific to the group owner. // One common case is creating a server thread and accepting // incoming connections. } else if (info.groupFormed) { // The other device acts as the client. In this case, // you'll want to create a client thread that connects to the group // owner. } }
@Override public void ConnectionInfoAvailable(WifiP2pInfo info) { if (info.isGroupOwner) { print_line("", "We are GROUP owner !!"); } else { mProgressDlg.dismiss(); print_line("", "Connected as Client !!"); Toast.makeText(getApplicationContext(),"Pairing successful, Do remember to pair from the other device as well !", Toast.LENGTH_LONG).show(); if(mWifiConnection != null) { mWifiConnection.Stop(); mWifiConnection = null; } mWifiAccessPoint = new WifiAccessPoint(that, mWifiBase.GetWifiP2pManager(), mWifiBase.GetWifiChannel(), that); mWifiAccessPoint.Start(); } }
public void onConnectionInfoAvailable(WifiP2pInfo info) { Log.d(ConnectService.TAG, "Connected"); Log.d(ConnectService.TAG, info.toString()); if (info.groupFormed){ context.setIsDeviceConnected(true); Log.d(ConnectService.TAG, "Connection established" + "\n" + "IP: " + info.groupOwnerAddress); if (!info.isGroupOwner){ this.context.addPeerAddress(info.groupOwnerAddress); } else { Log.d(ConnectService.TAG, "Waiting the IP address from the client"); IPAddressReceiver rec = new IPAddressReceiver(context); rec.receiveData(); } } else { context.setIsDeviceConnected(false); } }
public void onConnectionInfoAvailable(WifiP2pInfo info) { Log.d(StartActivity.TAG, "Connected"); Log.d(StartActivity.TAG, info.toString()); if (info.groupFormed){ context.setIsDeviceConnected(true); ((LinearLayout) context.findViewById(R.id.connectionLayout)).setVisibility(View.GONE); TextView text = (TextView) context.findViewById(R.id.connectionInfo); text.setText("Connection established"); text.setVisibility(View.VISIBLE); Log.d(StartActivity.TAG, "Waiting for incoming data"); if (info.isGroupOwner){ new ScreenDataReceiver(context).receiveData(); } else { context.sendIPAddress(info.groupOwnerAddress); } } else { context.setIsDeviceConnected(false); } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { host = info.groupOwnerAddress.getHostAddress(); serviceIntent = new Intent(synCarnet, TaskListTransferService.class); ServiceStatic.set(intent, synCarnet, host, info.isGroupOwner); progressDialog = ProgressDialog.show(synCarnet, synCarnet.getString(R.string.backCancel), synCarnet.getString(R.string.syncing), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }); synCarnet.syncService.setProgressDialog(progressDialog); synCarnet.startService(serviceIntent); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } this.info = info; this.getView().setVisibility(View.VISIBLE); // The owner IP is now known. TextView view = (TextView) mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo structure. view = (TextView) mContentView.findViewById(R.id.group_ip); view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // hide the connect button mContentView.findViewById(R.id.btn_connect).setVisibility(View.GONE); if (info.groupFormed && info.isGroupOwner) { } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { /* * Perform check to see who is group owner. This will determine which * device goes first. */ if (info.isGroupOwner) { Log.d(TAG, "Connected as group owner"); } else { new Thread(new WifiDirectClientRegistration(info.groupOwnerAddress)).start(); mController.addClientToList(new SwarmClient(info.groupOwnerAddress, Constants.CLIENT_DATA_PORT)); getAndPostNextWifiUploads(); Log.d(TAG, "Connected as peer"); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. Log.d(TAG, "Info available: "+info.toString()); if (info.groupFormed && info.isGroupOwner) { Log.d(TAG, "I AM THE SERVER"); transfer.startServer(); } else if (info.groupFormed) { Log.d(TAG, "I AM THE CLIENT"); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo p2pInfo) { wfd.setOpponentDeviceInformation(p2pInfo.toString()); Thread handler = null; /* * The group owner accepts connections using a server socket and then spawns a * client socket for every client. This is handled by {@code * GroupOwnerSocketHandler} */ if (p2pInfo.isGroupOwner) { Log.d(TAG, "Connected as group owner"); wfd.setSocketDeviceSide("server"); try { handler = new GroupOwnerSocketHandler(new Handler(this)); handler.start(); } catch (IOException e) { Log.d(TAG, "Failed to create a server thread - " + e.getMessage()); return; } } else { wfd.setSocketDeviceSide("client"); Log.d(TAG, "Connected as peer"); handler = new ClientSocketHandler( new Handler(this), p2pInfo.groupOwnerAddress); handler.start(); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { this.info = info; if (info.groupFormed){ final int N = mCallbacks.beginBroadcast(); for (int i=0; i<N; i++) { try { mCallbacks.getBroadcastItem(i).connectionDone(); } catch (RemoteException e) {} } mCallbacks.finishBroadcast(); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo p2pInfo) { Thread handler = null; /* * The group owner accepts connections using a server socket and then spawns a * client socket for every client. This is handled by {@code * GroupOwnerSocketHandler} */ if (p2pInfo.isGroupOwner) { Log.d(TAG, "Connected as group owner"); try { handler = new GroupOwnerSocketHandler( ((MessageTarget) this).getHandler()); handler.start(); } catch (IOException e) { Log.d(TAG, "Failed to create a server thread - " + e.getMessage()); return; } } else { Log.d(TAG, "Connected as peer"); handler = new ClientSocketHandler( ((MessageTarget) this).getHandler(), p2pInfo.groupOwnerAddress); handler.start(); } chatFragment = new WiFiChatFragment(); getFragmentManager().beginTransaction() .replace(R.id.container_root, chatFragment).commit(); statusTxtView.setVisibility(View.GONE); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { duration = System.currentTimeMillis() - startTime; Log.d(TAG, "onConnectionInfoAvailable: " + info + " (duration "+duration+" ms"); if (!info.isGroupOwner && info.groupFormed) { singleThreadExecutor.submit(new WifiClientRunnable(info.groupOwnerAddress, Constants.WIFI_SERVICE_PORT)); } }
/** * 接続した時のコールバックリスナーを呼び出す * @param info */ protected void callOnConnect(@NonNull final WifiP2pInfo info) { if (DEBUG) Log.v(TAG, "callOnConnect:"); for (final WiFiP2pListener listener: mListeners) { try { listener.onConnect(info); } catch (final Exception e1) { Log.w(TAG, e1); mListeners.remove(listener); } } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (DEBUG) Log.v(TAG, "onConnectionInfoAvailable:info=" + info); if (info != null) { callOnConnect(info); } }
/** * The requested connection info is available * @param wifiP2pInfo Wi-Fi P2P connection info */ @Override public void onConnectionInfoAvailable(WifiP2pInfo wifiP2pInfo) { Log.i(TAG, "Connection info available"); Log.i(TAG, "WifiP2pInfo: "); Log.i(TAG, p2pInfoToString(wifiP2pInfo)); this.groupFormed = wifiP2pInfo.groupFormed; this.isGroupOwner = wifiP2pInfo.isGroupOwner; if (wifiP2pInfo.groupFormed) { if(stopDiscoveryAfterGroupFormed){ stopServiceDiscovery(); } // Thread handler; if (wifiP2pInfo.isGroupOwner && socketHandler == null) { Log.i(TAG, "Connected as group owner"); try { socketHandler = new OwnerSocketHandler(this.getHandler()); socketHandler.start(); } catch (IOException e) { Log.e(TAG, "Failed to create a server thread - " + e.getMessage()); return; } } else { Log.i(TAG, "Connected as peer"); socketHandler = new ClientSocketHandler(this.getHandler(), wifiP2pInfo.groupOwnerAddress); socketHandler.start(); } // localBroadcastManager.sendBroadcast(new Intent(Action.SERVICE_CONNECTED)); } else { Log.w(TAG, "Group not formed"); } localBroadcastManager.sendBroadcast(new Intent(Action.DEVICE_CHANGED)); }
public String p2pInfoToString(WifiP2pInfo wifiP2pInfo) { if (wifiP2pInfo != null) { String strWifiP2pInfo = "Group formed: " + wifiP2pInfo.groupFormed; strWifiP2pInfo += "\nIs group owner: " + wifiP2pInfo.isGroupOwner; strWifiP2pInfo += "\nGroup owner address: " + wifiP2pInfo.groupOwnerAddress; return strWifiP2pInfo; } else { Log.e(TAG, "WifiP2pInfo is null"); return ""; } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } this.info = info; this.getView().setVisibility(View.VISIBLE); // The owner IP is now known. TextView view = (TextView) mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo struct. view = (TextView) mContentView.findViewById(R.id.device_info); view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. if (info.groupFormed && info.isGroupOwner) { new FileServerAsyncTask(getActivity(), mContentView.findViewById(R.id.status_text)) .execute(); } else if (info.groupFormed) { // The other device acts as the client. In this case, we enable the // get file button. mContentView.findViewById(R.id.btn_start_client).setVisibility(View.VISIBLE); ((TextView) mContentView.findViewById(R.id.status_text)).setText(getResources() .getString(R.string.client_text)); } // hide the connect button mContentView.findViewById(R.id.btn_connect).setVisibility(View.GONE); }
/** * Connected with the other peer. * This method is called after connection success. * GROUP OWNER = Server (receives the ack messages). * Update isConnected value and get the Server IP address. * If I'm the Server, instantiate the ServerAckReceiver. * If I'm the Client, now I'm ready to receive new incoming messages, make QR scan available. * * @param info the info about this connection. */ @Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { // Now I'm connected isConnected = true; if (info.groupFormed){ // Connection established. // Get the serverAddress (used for socket connection). serverIPAddress = info.groupOwnerAddress.getHostAddress(); if ((iAmTheServer && !info.isGroupOwner)||(!iAmTheServer && info.isGroupOwner)){ // Error, the Group Owner is not also the Server, devices must be inverted! Toast.makeText(getApplicationContext(), R.string.aqrdt_error_invert_devices, Toast.LENGTH_SHORT).show(); } else if (iAmTheServer) { // I'm the Server, instantiate the ServerAckReceiver if (mServerReceiver == null) { mServerReceiver = new ServerAckReceiver(TransferActivity.this); mServerReceiver.execute(); } } else { // I'm the Client, make QR code scan available. makeQRscanAvailable(true); } } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { Log.d("Client","connection info listener on connection info available"); // InetAddress from WifiP2pInfo struct. groupOwnerAddress = info.groupOwnerAddress; InitSocketTask initSocketTask = new InitSocketTask(Client.this); initSocketTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { Log.d("Client", "connection info listener on connection info available"); // InetAddress from WifiP2pInfo struct. client.setGroupOwnerAddress(info.groupOwnerAddress); InitSocketTask initSocketTask = new InitSocketTask(client); initSocketTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { if (info.groupFormed && info.isGroupOwner) { // group owner starts the server Log.d(TAG, "Connection Info Changed: Connected [Client]"); new Server(8090, this).execute(); } else if (info.groupFormed) { // and the other party connects to it Log.d(TAG, "Connection Info Changed: Connected [Server]"); new Client(info.groupOwnerAddress, 8090, this).execute(); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { try { callback.ConnectionInfoAvailable(info); } catch(Exception e) { debug_print("onConnectionInfoAvailable, error: " + e.toString()); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { try { callback.ConnectionInfoAvailable(info); if (info.isGroupOwner) { p2p.requestGroupInfo(channel,this); } else { debug_print("we are client !! group owner address is: " + info.groupOwnerAddress.getHostAddress()); } } catch(Exception e) { debug_print("onConnectionInfoAvailable, error: " + e.toString()); } }
@Override public void onConnectionInfoAvailable(WifiP2pInfo info) { if (info.groupFormed) { ctx.groupOwnerAddress = info.groupOwnerAddress; ctx.isGroupOwner = info.isGroupOwner; ctx.isWifiP2pConnected = true; onFinished(STA_SUCCESS, info); } else { ctx.groupOwnerAddress = null; ctx.isGroupOwner = false; ctx.isWifiP2pConnected = false; onFinished(STA_FAIL); } }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { /* This method is automatically called when we connect to a device. * The group owner accepts connections using a server socket and then spawns a * client socket for every client. This is handled by the registration jobs. * This will automatically handle first time connections.*/ manager.requestGroupInfo(channel, new WifiP2pManager.GroupInfoListener() { @Override public void onGroupInfoAvailable(WifiP2pGroup group) { if (isRunningAsHost && !registrationIsRunning) { if (info.groupFormed && !group.getClientList().isEmpty()) { startHostRegistrationServer(); } } else if (!thisDevice.isRegistered && !info.isGroupOwner) { if (serviceRequest == null) { //This means that discoverNetworkServices was never called and we're still connected to an old host for some reason. Log.e(Salut.TAG, "This device is still connected to an old host for some reason. A forced disconnect will be attempted."); forceDisconnect(); } Log.v(Salut.TAG, "Successfully connected to another device."); startRegistrationForClient(new InetSocketAddress(info.groupOwnerAddress.getHostAddress(), SALUT_SERVER_PORT)); } } }); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { InetAddress address = info.groupOwnerAddress; if(info.groupFormed && info.isGroupOwner) { //start server and make others connect ScatterLogManager.i(TAG, "Device is the group owner with address " + address.toString()); } else if(info.groupFormed) { ScatterLogManager.i(TAG, "Device is connected to group with address "+ address.toString()); //connect to group leader } }
public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } this.info = info; // The owner IP is now known. // TextView view = (TextView) mContentView.findViewById(R.id.group_owner); // view.setText(getResources().getString(R.string.group_owner_text) // + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) // : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo struct. deviceInfoTextView.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. if (info.groupFormed && info.isGroupOwner) { new FileServerAsyncTask(getActivity(), statusTextView).execute(); } else if (info.groupFormed) { // The other device acts as the client. In this case, we enable the // get file button. startTransferButton.setVisibility(View.VISIBLE); statusTextView.setText(getResources().getString(R.string.client_text)); } // hide the connect button manageButtons(); }
private void notify_connectivity_changed(final WifiP2pInfo p2pInfo, final NetworkInfo networkInfo, final WifiP2pGroup group) { executorService.execute(new Runnable() { @Override public void run() { for (IBlaubotWifiDirectEventListener listener : eventListeners) { listener.onConnectivityChanged(p2pInfo, networkInfo, group); } } }); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } Log.d(WiFiDirectActivity.TAG, "onConnectionInfoAvailable - " + info); if (!info.groupFormed) { return; } this.info = info; this.getView().setVisibility(View.VISIBLE); // The owner IP is now known. TextView view = (TextView) mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo struct. view = (TextView) mContentView.findViewById(R.id.device_info); view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. if (info.groupFormed && info.isGroupOwner) { new FileServerAsyncTask(getActivity(), mContentView.findViewById(R.id.status_text)) .execute(); } else if (info.groupFormed) { // The other device acts as the client. In this case, we enable the // get file button. mContentView.findViewById(R.id.btn_start_client).setVisibility(View.VISIBLE); ((TextView) mContentView.findViewById(R.id.status_text)).setText(getResources() .getString(R.string.client_text)); } // hide the connect button mContentView.findViewById(R.id.btn_connect).setVisibility(View.GONE); }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (mGroupActor != null) { return; } WfdLog.d(TAG, "connection info available"); if (!info.groupFormed) { createGroup(); return; } WfdLog.d(TAG, "group formed"); if (info.isGroupOwner) { instantiateGroupOwner(); } else { mManager.requestGroupInfo(mChannel, new GroupInfoListener() { @Override public void onGroupInfoAvailable(WifiP2pGroup arg0) { if (arg0 == null) { // happens when the go goes away and the // framework does not have time to update the // connection loss return; } WifiP2pDevice groupOwnerDevice = arg0.getOwner(); Integer destPort = mPorts.get(groupOwnerDevice.deviceAddress); if (destPort == null) { Log.e(TAG, "null destPort for group owner"); mManager.removeGroup(mChannel, null); } instantiateGroupClient(info.groupOwnerAddress, destPort); } }); } }
public void onConnectionInfoAvailable(WifiP2pInfo info) { ChatInfo.setGroupOwner(info.isGroupOwner); ChatInfo.setGroupOwnerAddress(info.groupOwnerAddress); Intent i = new Intent(getApplicationContext(), ChatActivity.class); startActivity(i); }
public WifiDirectConnect(Context context) { mManager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE); mChannel = mManager.initialize(context, context.getMainLooper(), null); mContext = context; mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) { if (mManager == null) { return; } NetworkInfo networkInfo = (NetworkInfo) intent .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO); if (networkInfo.isConnected()) { mManager.requestConnectionInfo(mChannel, new WifiP2pManager.ConnectionInfoListener() { @Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (mDevice != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http:/" + info.groupOwnerAddress + ":" + Integer.toString(Utils.getWifiPort(mDevice)))); mContext.startActivity(intent); close(); } } }); } } } }; }
@Override public void onConnectionInfoAvailable(final WifiP2pInfo info) { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } this.info = info; if(this.getView().getVisibility()!=View.VISIBLE) this.getView().setVisibility(View.VISIBLE); mContentView.findViewById(R.id.connect).setVisibility(View.GONE); mContentView.findViewById(R.id.disconnect).setVisibility(View.VISIBLE); isConnected=true; // The owner IP is now known. TextView view = (TextView) mContentView.findViewById(R.id.group_owner); view.setText(getResources().getString(R.string.group_owner_text) + ((info.isGroupOwner == true) ? getResources().getString(R.string.yes) : getResources().getString(R.string.no))); // InetAddress from WifiP2pInfo struct. view = (TextView) mContentView.findViewById(R.id.device_info); view.setText("Group Owner IP - " + info.groupOwnerAddress.getHostAddress()); // After the group negotiation, we assign the group owner as the file // server. The file server is single threaded, single connection server // socket. if (info.groupFormed && info.isGroupOwner) { new FileServerAsyncTask(getActivity(), mContentView.findViewById(R.id.status_text)) .execute(); } else if (info.groupFormed) { // The other device acts as the client. In this case, we enable the // get file button. mContentView.findViewById(R.id.btn_start_client).setVisibility(View.VISIBLE); ((TextView) mContentView.findViewById(R.id.status_text)).setText(getResources() .getString(R.string.client_text)); } }