2

我的 android SDK 是 API:25

我找到了使用下面的代码设置 captive_portal_detection_enabled 的答案。

所以,如果它在一个有围墙的花园里,我可以避开感叹号。

 Settings.Global.putInt(MainActivity.this.getContentResolver(), "captive_portal_detection_enabled", 0);

现在,我想用上面的代码更改三个值:

  1. captive_portal_server
  2. captive_portal_http_url
  3. captive_portal_https_url

我用

 Settings.Global.putString(MainActivity.this.getContentResolver(), "captive_portal_server ", ServerList.get(position));
            Settings.Global.putString(MainActivity.this.getContentResolver(), "captive_portal_http_url  ", "http://"+ServerList.get(position)+"/generate_204");
            Settings.Global.putString(MainActivity.this.getContentResolver(), "captive_portal_https_url  ", "https://"+ServerList.get(position)+"/generate_204");
            Toast.makeText(MainActivity.this, "Captive portal server is now : " + server()
                                            +"\nCaptive portal http_url is now : "+http_url()
                                            +"\nCaptive portal https_url is now : "+https_url(), Toast.LENGTH_SHORT).show();

我总是得到server()、http_url()、https_url() 的空值。

    private String server(){
    return Settings.Global.getString(MainActivity.this.getContentResolver(), "captive_portal_server");
}
private String http_url(){
    return Settings.Global.getString(MainActivity.this.getContentResolver(), "captive_portal_http_url");
}
private String https_url(){
    return Settings.Global.getString(MainActivity.this.getContentResolver(), "captive_portal_https_url");
}

请帮我解决它!

顺便一提!!!如何检查网址是否为服务器?!!!

4

0 回答 0