Java Code Examples for android.net.wifi.p2p.WifiP2pDevice#CONNECTED
The following examples show how to use
android.net.wifi.p2p.WifiP2pDevice#CONNECTED .
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: WifiDirectManager.java From ShareBox with Apache License 2.0 | 6 votes |
public static String getDeviceStatus(int deviceStatus) { switch (deviceStatus) { case WifiP2pDevice.AVAILABLE: return "Available"; case WifiP2pDevice.INVITED: return "Invited"; case WifiP2pDevice.CONNECTED: return "Connected"; case WifiP2pDevice.FAILED: return "Failed"; case WifiP2pDevice.UNAVAILABLE: return "Unavailable"; default: return "Unknown error"; } }
Example 2
Source File: WiFiP2pHelper.java From libcommon with Apache License 2.0 | 6 votes |
/** * 切断する */ protected void internalDisconnect(final WifiP2pManager.ActionListener listener) { if (DEBUG) Log.v(TAG, "internalDisconnect:"); if (mWifiP2pManager != null) { if ((mWifiP2pDevice == null) || (mWifiP2pDevice.status == WifiP2pDevice.CONNECTED)) { // 接続されていないか、既に接続済みの時 if (mChannel != null) { mWifiP2pManager.removeGroup(mChannel, listener); } } else if (mWifiP2pDevice.status == WifiP2pDevice.AVAILABLE || mWifiP2pDevice.status == WifiP2pDevice.INVITED) { // ネゴシエーション中の時 mWifiP2pManager.cancelConnect(mChannel, listener); } } }
Example 3
Source File: WiFiDirectActivity.java From Demo_Public with MIT License | 6 votes |
@Override public void cancelDisconnect() { if(mManager != null){ final DeviceListFragment fragment = (DeviceListFragment)getFragmentManager().findFragmentById(R.id.frag_list); if(fragment.getDevice() == null || fragment.getDevice().status == WifiP2pDevice.CONNECTED){ disconnect(); }else if(fragment.getDevice().status == WifiP2pDevice.AVAILABLE || fragment.getDevice().status == WifiP2pDevice.INVITED){ mManager.cancelConnect(mChannel, new WifiP2pManager.ActionListener() { @Override public void onSuccess() { } @Override public void onFailure(int reason) { } }); } } }
Example 4
Source File: DeviceListFragment.java From Demo_Public with MIT License | 6 votes |
private static String getDeviceStatus(int deviceStatus){ Log.e(WiFiDirectActivity.TAG, "Peer status: "+deviceStatus); switch(deviceStatus){ case WifiP2pDevice.AVAILABLE: return "Avaiable"; case WifiP2pDevice.INVITED: return "Invited"; case WifiP2pDevice.CONNECTED: return "Conntend"; case WifiP2pDevice.FAILED: return "Failed"; case WifiP2pDevice.UNAVAILABLE: return "Unavailable"; default: return "Unkonw"; } }
Example 5
Source File: WifiDirectHandler.java From WiFi-Buddy with MIT License | 6 votes |
/** * Translates a device status code to a readable String status * @param status * @return A readable String device status */ public String deviceStatusToString(int status) { if (status == WifiP2pDevice.AVAILABLE) { return "Available"; } else if (status == WifiP2pDevice.INVITED) { return "Invited"; } else if (status == WifiP2pDevice.CONNECTED) { return "Connected"; } else if (status == WifiP2pDevice.FAILED) { return "Failed"; } else if (status == WifiP2pDevice.UNAVAILABLE) { return "Unavailable"; } else { return "Unknown"; } }
Example 6
Source File: ActivityManageP2P.java From nfcspy with GNU General Public License v3.0 | 6 votes |
private CharSequence getWifiP2pDeviceStatus(WifiP2pDevice dev) { switch (dev.status) { case WifiP2pDevice.CONNECTED: return getString(R.string.status_p2p_connected); case WifiP2pDevice.INVITED: return getString(R.string.status_p2p_invited); case WifiP2pDevice.FAILED: return getString(R.string.status_p2p_failed); case WifiP2pDevice.AVAILABLE: return getString(R.string.status_p2p_available); case WifiP2pDevice.UNAVAILABLE: default: return getString(R.string.status_p2p_unavailable); } }
Example 7
Source File: DeviceListFragment.java From commcare-android with Apache License 2.0 | 6 votes |
private static String getDeviceStatus(int deviceStatus) { Log.d(TAG, "Peer status :" + deviceStatus); switch (deviceStatus) { case WifiP2pDevice.AVAILABLE: return "Available"; case WifiP2pDevice.INVITED: return "Invited"; case WifiP2pDevice.CONNECTED: return "Connected"; case WifiP2pDevice.FAILED: return "Failed"; case WifiP2pDevice.UNAVAILABLE: return "Unavailable"; default: return "Unknown"; } }
Example 8
Source File: WifiListAdapter.java From Wifi-Connect with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(CustomViewHolder holder, int position) { WifiP2pDevice device = getItem(position); holder.itemTitle.setText(device.deviceName); if(device.status == WifiP2pDevice.CONNECTED) { holder.itemDesc.setText(context.getString(R.string.connected)); holder.itemDesc.setTextColor(Color.GREEN); } else { holder.itemDesc.setText(device.deviceAddress); holder.itemDesc.setTextColor(ContextCompat.getColor(context, R.color.fragment_add_bank_desc)); } }
Example 9
Source File: WifiDirectManager.java From ShareBox with Apache License 2.0 | 5 votes |
public void disconnectWifiDirect() { if (mWifiP2pDevice != null) { ALog.i(TAG, "disconnectWifiDirect mWifiP2pDevice.status:" + mWifiP2pDevice.status); if (mWifiP2pDevice.status == WifiP2pDevice.CONNECTED) { disconnect(); } else if (mWifiP2pDevice.status == WifiP2pDevice.AVAILABLE || mWifiP2pDevice.status == WifiP2pDevice.INVITED) { cancelConnect(); } } }
Example 10
Source File: ActivityManageP2P.java From nfcspy with GNU General Public License v3.0 | 5 votes |
void handlePeerListClick(int index) { WifiP2pDevice dev = peerdevs.get(index); if (dev.status == WifiP2pDevice.CONNECTED || dev.status == WifiP2pDevice.INVITED) { disconnectPeer(dev); } else if (dev.status != WifiP2pDevice.UNAVAILABLE) { connectPeer(dev); } }
Example 11
Source File: WifiP2PServiceImpl.java From Wifi-Connect with Apache License 2.0 | 4 votes |
@Override public synchronized void handleOnDeviceStatusChanged(WifiP2pDevice wifiP2pDevice) { if(wifiP2pDevice.status == WifiP2pDevice.CONNECTED) { // handleOnPeerConnected(); } }
Example 12
Source File: WiFiP2pHelper.java From libcommon with Apache License 2.0 | 4 votes |
/** * WiFi Directで接続を試みているか接続しているかどうか * @return */ public synchronized boolean isConnectedOrConnecting() { return (mWifiP2pDevice != null) && ((mWifiP2pDevice.status == WifiP2pDevice.CONNECTED) || (mWifiP2pDevice.status == WifiP2pDevice.INVITED)); }
Example 13
Source File: WiFiP2pHelper.java From libcommon with Apache License 2.0 | 2 votes |
/** * WiFi Directで接続されているかどうか * @return */ public synchronized boolean isConnected() { return (mWifiP2pDevice != null) && (mWifiP2pDevice.status == WifiP2pDevice.CONNECTED); }