我使用以下代码创建Wifi-hotspot配置.我能够创建Hotspot配置并能够启用它.但我已经为WPA-PSK提供了配置,但它始终作为OPEN网络.
public boolean setHotSpot(String SSID,String passWord){
Method[] mMethods = mWifiManager.getClass().getDeclaredMethods();
for(Method mMethod: mMethods){
if(mMethod.getName().equals("setWifiApEnabled")) {
WifiConfiguration netConfig = new WifiConfiguration();
netConfig.SSID = SSID ;
netConfig.preSharedKey = passWord;
netConfig.hiddenSSID = true;
netConfig.status = WifiConfiguration.Status.ENABLED;
netConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
netConfig.allowedKeyManagement.set(4);
netConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
netConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
netConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
netConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
netConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
netConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
try {
mMethod.invoke(mWifiManager, netConfig,true);
mWifiManager.saveConfiguration();
return true;
} catch (Exception e) {
e.printStackTrace();
CommonUtil.log(TAG,"Exception : "+e.getLocalizedMessage());
}
}
}
return false;
Run Code Online (Sandbox Code Playgroud)
}
运行此应用程序后,Hotspot已启用.请查看下面的图片.
如何在Android应用程序中设置WPA_PSK wifi配置?
根据以下答案,我修改了下面的代码.
public boolean setHotSpot(String SSID, String passWord) {
boolean apstatus;
WifiConfiguration netConfig …Run Code Online (Sandbox Code Playgroud) android wifimanager android-wifi personal-hotspot wificonfiguration
我需要编写一个简单的应用程序来获取PUSH通知.
我使用了使用Google Play服务获取信息的GCM.
我的问题是 - 要访问GCM,是否需要Google帐户?
我可以使用其他电子邮件帐户来识别设备吗?
有没有其他方法可以获得其他电子邮件帐户或设备的推送通知?