我需要在Android 2.2(Froyo)中创建一个API调用来创建一个Wifi热点(如Tethering和Portable Hotspot设置项中所示).
在Android 1.5(也在1.6)
如何从代码中添加Access Point?
给定支持WPA2的接入点.这是我的代码片段.
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiConfiguration wc = new WifiConfiguration();
// This is must be quoted according to the documentation
// http://developer.android.com/reference/android/net/wifi/WifiConfiguration.html#SSID
wc.SSID = "\"SSIDName\"";
wc.preSharedKey = "password";
wc.hiddenSSID = true;
wc.status = WifiConfiguration.Status.ENABLED;
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
int res = wifi.addNetwork(wc);
Log.d("WifiPreference", "add Network returned " + res );
boolean b = wifi.enableNetwork(res, true);
Log.d("WifiPreference", "enableNetwork returned " + b );
Run Code Online (Sandbox Code Playgroud)
此代码失败,因为在LogCat中出现
01-26 16:44:13.550:ERROR/wpa_supplicant(2032):第0行:PSK'密码'无效.
我确信这是密码,所有其他参数都是正确的.我想念我怎么办?
我是Jaemoon.
我的系统应用程序位于/ system/app中运行良好,直到Android 4.3 Jelly Bean,但它开始出现一些问题,这是Android 4.4 KitKat中的安全问题.
换句话说,我的系统应用程序需要权限,如android.permission.WRITE_APN_SETTINGS和android.permission.CONNECTIVITY_INTERNAL,并且直到Jelly Bean,但是从KitKat,安全问题如下.我不明白为什么我的系统应用程序在Jelly Bean中运行良好的原因导致KitKat出现安全问题.
我怀疑KitKat是否需要在某些脚本文件中进行新设置以获得系统权限.任何人都可以帮助我或指导我吗?
---------------------------------------------------------------------
java.lang.SecurityException: No permission to write APN settings: Neither user 10146 nor current process has android.permission.WRITE_APN_SETTINGS.
...
---------------------------------------------------------------------
java.lang.SecurityException: ConnectivityService: Neither user 10097 nor current process has android.permission.CONNECTIVITY_INTERNAL.
---------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
提前致谢..