本文整理匯總了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);
}
示例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
}
示例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();
}
}
示例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.
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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) {
}
}
示例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");
}
}
示例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");
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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));
}
}