當前位置: 首頁>>代碼示例>>Java>>正文


Java WifiP2pInfo類代碼示例

本文整理匯總了Java中android.net.wifi.p2p.WifiP2pInfo的典型用法代碼示例。如果您正苦於以下問題:Java WifiP2pInfo類的具體用法?Java WifiP2pInfo怎麽用?Java WifiP2pInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WifiP2pInfo類屬於android.net.wifi.p2p包,在下文中一共展示了WifiP2pInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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);
}
 
開發者ID:coderminer,項目名稱:Demo_Public,代碼行數:24,代碼來源:DeviceDetailFragment.java

示例2: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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

}
 
開發者ID:lucky-code,項目名稱:Practice,代碼行數:26,代碼來源:DeviceDetailFragment.java

示例3: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:niyueming,項目名稱:WiFiP2PDemo,代碼行數:21,代碼來源:WiFiP2PBroadcastReceiver.java

示例4: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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.
    }
}
 
開發者ID:ritave,項目名稱:RevolutionStarbucks,代碼行數:23,代碼來源:WifiReceiver.java

示例5: ConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:DrJukka,項目名稱:WifiPairing,代碼行數:20,代碼來源:MainActivity.java

示例6: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
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);
	}

   
}
 
開發者ID:andrebask,項目名稱:expo-connect,代碼行數:23,代碼來源:ConnectionInfo.java

示例7: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
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);
	}

   
}
 
開發者ID:andrebask,項目名稱:expo-connect,代碼行數:24,代碼來源:ConnectionInfo.java

示例8: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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);
}
 
開發者ID:npmiller,項目名稱:syncarnet,代碼行數:17,代碼來源:PeerList.java

示例9: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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) {

    } 
}
 
開發者ID:itamaro,項目名稱:higgs-bot,代碼行數:27,代碼來源:DeviceDetailFragment.java

示例10: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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");
    }
}
 
開發者ID:lolletsoc,項目名稱:dissertation-project,代碼行數:17,代碼來源:PieceUploadService.java

示例11: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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");
    }
}
 
開發者ID:mDL-ILP,項目名稱:mDL-ILP,代碼行數:15,代碼來源:WiFiDirectConnection.java

示例12: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:jphacks,項目名稱:TK_1701,代碼行數:32,代碼來源:WiFiDirectCommunicator.java

示例13: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:14,代碼來源:FileTransferService.java

示例14: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:33,代碼來源:WiFiServiceDiscoveryActivity.java

示例15: onConnectionInfoAvailable

import android.net.wifi.p2p.WifiP2pInfo; //導入依賴的package包/類
@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));
    }
}
 
開發者ID:coinblesk,項目名稱:coinblesk-client-gui,代碼行數:9,代碼來源:WiFiClient.java


注:本文中的android.net.wifi.p2p.WifiP2pInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。