如何忘记的Andr​​oid无线网络编程? [英] How to forget a wireless network in android programmatically?

查看:202
本文介绍了如何忘记的Andr​​oid无线网络编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序无线网络,在那里用户将被要求输入密码,扫描网络,他选择,如果用户输入正确的密码,它连接和行之有效的。但是,当用户输入错误的密码,一个新的网络被添加具有该名称,并且将未认证的密码错误两面,并且应当具有鉴定问题状态

I am working on an app which wifi , where user will be asked to enter password for the scanned network he selects, if user enters a correct password, it connects and works well. But when user enters wrong password, a new network is added with that name, and will be failing to authenticate cos of wrong password, and it will be having authentication problem status.

现在,如果用户尝试再次扫描,并选择在同一网络,并输入正确的密码,连接失败,即使密码现在是正确的,将有禁用状态,因为previous连接仍然表明身份验证问题状态。

Now if user tries to again scan and select the same network, and enters correct password, it fails to connect even though password now is correct and will have disabled status, since the previous connection is still showing that authentication problem status.

如何解决这个问题呢? 有没有什么办法忘记使用ConnectivityManager或wifimanager所有网络?还是有其他的解决办法?

How to solve this problem? Is there any way to forget all networks using ConnectivityManager or wifimanager? Or any other solution?

推荐答案

WifiManager 源$ C ​​$ C,有这样的方法:

in the WifiManager source code, has this method:

/**
     * Delete the network in the supplicant config.
     *
     * This function is used instead of a sequence of removeNetwork()
     * and saveConfiguration().
     *
     * @param config the set of variables that describe the configuration,
     *            contained in a {@link WifiConfiguration} object.
     * @hide
     */

    public void forgetNetwork(int netId) {
        if (netId < 0) {
            return;
        }

        mAsyncChannel.sendMessage(CMD_FORGET_NETWORK, netId);
    }

但这种方法是 @hide ,我们不能用这个,但是通过这种方法文档:

but this method is @hide, we can't use this, but through this method document:

此功能时 removeNetwork的序列,而不是()和    saveConfiguration()

所以你可以尝试使用: removeNetwork() saveConfiguration()

so you can try use: removeNetwork() and saveConfiguration()

这篇关于如何忘记的Andr​​oid无线网络编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆