我通过谷歌文档,发现如果WiFi P2P支持的设备,那么它显然它支持WiFi热点
通过设备检查Wi-Fi Direct / WiFi P2P,然后检查这种方式
PackageManager m = getPackageManager();
if (!m.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)) {
// This device does support wifi P2P
}
但是谷歌表示,更好地通过这种方式在广播接收器本身中检查此支持
@Override
public void onReceive(Context context, Intent intent) {
...
String action = intent.getAction();
if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
// Wifi P2P is enabled
} else {
// Wi-Fi P2P is not enabled
}
}
...
}