是否有可能切换无线网络共享中的Android 4.2?我尝试this但似乎,它并没有使用Android的工作4.2!
Is there any possibility to toggle wifi tethering in Android 4.2? I tried this but it seems that it doesn't work using Android 4.2!
在此先感谢!
编辑:它的工作,我只是忘了设置正确的权限。有没有还的方法来检查其是否已经启用,这样我可以把它作为一个切换?
It DOES work I only forgot to set the right permission. Is there also a way to check if its already enabled so that I can use it as a toggle?
您应该能够做到这一点在安卓4.2请确保您有权限
You should be able to do it in Android 4.2 make sure you have the permission
android.permission.CHANGE_WIFI_STATE
和我们帮不了你,除非你发表您的code。
and we cannot help you unless you post your code.
我相信这将帮助你检查网络共享处于活动状态
I believe this will help you check if tethering is active
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
Method[] wmMethods = wifi.getClass().getDeclaredMethods();
for(Method method: wmMethods){
if(method.getName().equals("isWifiApEnabled")) {
try {
method.invoke(wifi);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
上一篇:更新SQLite数据库的版本?版本、数据库、SQLite
下一篇:凡片段时保存其状态FragmentTransaction.Replace?片段、状态、Replace、FragmentTransaction