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


Java WifiP2pDevice類代碼示例

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


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

示例1: onPeersAvailable

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
@Override
public void onPeersAvailable(WifiP2pDeviceList wifiP2pDeviceList) {

    if (!connectionAttemptInProgress.compareAndSet(false, true)) {
        return;
    }

    if (connected.get()) {
        return;
    }

    for (WifiP2pDevice device : wifiP2pDeviceList.getDeviceList()) {
        if (device.deviceAddress.equals(target)) {
            WifiP2pConfig config = new WifiP2pConfig();
            config.deviceAddress = device.deviceAddress;
            config.wps.setup = WpsInfo.PBC;
            config.groupOwnerIntent = 0; // I want the other device to be the group owner (or 'server')

            Log.d(TAG, "Trying to connect to "+device.deviceAddress+" "+device.deviceName+" Owner: "+device.isGroupOwner());

            connect(config);
            break;
        }
    }
}
 
開發者ID:mDL-ILP,項目名稱:mDL-ILP,代碼行數:26,代碼來源:WiFiDirectConnection.java

示例2: getP2pDeviceStatus

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
private static String getP2pDeviceStatus(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";
    }
}
 
開發者ID:jphacks,項目名稱:TK_1701,代碼行數:18,代碼來源:WiFiDirect.java

示例3: getDeviceStatus

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
static String getDeviceStatus(int deviceStatus) {
    Log.d(FileTransferService.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";
    }
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:18,代碼來源:Utils.java

示例4: connectToPeer

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
private void connectToPeer (WifiP2pDevice device)
{
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.deviceAddress;
    config.wps.setup = WpsInfo.PBC;

    mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {

        @Override
        public void onSuccess() {
            // WiFiDirectBroadcastReceiver will notify us. Ignore for now.
        }

        @Override
        public void onFailure(int reason) {

        }
    });

}
 
開發者ID:n8fr8,項目名稱:LittleBitLouder,代碼行數:21,代碼來源:WifiP2pSender.java

示例5: getDeviceStatus

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
private static String getDeviceStatus(int deviceStatus) {
    Log.d(WiFiDirectActivity.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";

    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:19,代碼來源:DeviceListFragment.java

示例6: getView

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) getActivity().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.row_devices, null);
    }
    WifiP2pDevice device = items.get(position);
    if (device != null) {
        TextView top = (TextView) v.findViewById(R.id.device_name);
        TextView bottom = (TextView) v.findViewById(R.id.device_details);
        if (top != null) {
            top.setText(device.deviceName);
        }
        if (bottom != null) {
            bottom.setText(getDeviceStatus(device.status));
        }
    }

    return v;

}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:24,代碼來源:DeviceListFragment.java

示例7: getDeviceStatus

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
public static String getDeviceStatus(int statusCode) {
    switch (statusCode) {
        case WifiP2pDevice.CONNECTED:
            return "Connected";
        case WifiP2pDevice.INVITED:
            return "Invited";
        case WifiP2pDevice.FAILED:
            return "Failed";
        case WifiP2pDevice.AVAILABLE:
            return "Available";
        case WifiP2pDevice.UNAVAILABLE:
            return "Unavailable";
        default:
            return "Unknown";

    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:WiFiDirectServicesList.java

示例8: internalDisconnect

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
/**
 * 切斷する
 */
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);
		}
	}
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:21,代碼來源:WiFiP2pHelper.java

示例9: getDeviceStatus

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
private static String getDeviceStatus(int deviceStatus) {
    Log.d(WiFiDirectActivity.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";

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

示例10: cancelDisconnect

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

示例11: getDeviceStatus

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

示例12: getView

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if(v ==  null){
        LayoutInflater vi = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.row_devices, null);
    }
    WifiP2pDevice device = items.get(position);
    if(device != null){
        TextView top = (TextView)v.findViewById(R.id.device_name);
        TextView bottom = (TextView)v.findViewById(R.id.device_details);
        if(null != top){
            top.setText(device.deviceName);
        }
        if(null != bottom){
            bottom.setText(device.deviceAddress);
        }
    }
    return v;
}
 
開發者ID:coderminer,項目名稱:Demo_Public,代碼行數:21,代碼來源:DeviceListFragment.java

示例13: p2pDeviceToString

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
/**
 * Takes a WifiP2pDevice and returns a String of readable device information
 * @param wifiP2pDevice
 * @return
 */
public String p2pDeviceToString(WifiP2pDevice wifiP2pDevice) {
    if (wifiP2pDevice != null) {
        String strDevice = "Device name: " + wifiP2pDevice.deviceName;
        strDevice += "\nDevice address: " + wifiP2pDevice.deviceAddress;
        if (wifiP2pDevice.equals(thisDevice)) {
            strDevice += "\nIs group owner: " + isGroupOwner();
        } else {
            strDevice += "\nIs group owner: false";
        }
        strDevice += "\nStatus: " + deviceStatusToString(wifiP2pDevice.status) + "\n";
        return strDevice;
    } else {
        Log.e(TAG, "WifiP2pDevice is null");
        return "";
    }
}
 
開發者ID:Crash-Test-Buddies,項目名稱:WiFi-Buddy,代碼行數:22,代碼來源:WifiDirectHandler.java

示例14: deviceStatusToString

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
/**
 * 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";
    }
}
 
開發者ID:Crash-Test-Buddies,項目名稱:WiFi-Buddy,代碼行數:21,代碼來源:WifiDirectHandler.java

示例15: WifiP2pHelper

import android.net.wifi.p2p.WifiP2pDevice; //導入依賴的package包/類
public WifiP2pHelper(final MainActivity activity, Handler handler) {
    this.activity = activity;
    this.handler = handler;
    manager = (WifiP2pManager) activity
            .getSystemService(Context.WIFI_P2P_SERVICE);
    channel = manager.initialize(activity, activity.getMainLooper(), null);
    deviceList = new ArrayList<WifiP2pDevice>();
    sendingFileList = new ArrayList<>();
    updateWifiMac();
}
 
開發者ID:lucky-code,項目名稱:Practice,代碼行數:11,代碼來源:WifiP2pHelper.java


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