开发者

Is there ability programly adjust wifi if it is disabled

Is 开发者_运维问答there ability programly adjust wifi if it is disabled.

— if wifi is disabled: WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); wifiManager.addNetwork(wifiConf)

addNetwork function return -1

— If wifi is enabled it works fine.


If wifi is enabled "addNetwork" function works fine and new network is added. In the same situation, but wifi is disabled "addNetwork" function return -1 and new network is not added – Andrey 46 mins ago I want adjust wifi even if wifi is disabled

thanks.


Install the package urfkill.

Use the command...

# rfkill unblock wifi

...to turn wifi on.

You may need to make sure the hardware switch, if there is one, is in the correct position, too.


You can check if you are currently connected to any network using this

ConnectivityManager manager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
manager.getNetworkInfo(ConnectionManager.CONNECTION_WIFI).getState() == NetworkInfo.State.CONNECTED;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜