在没有 webview 的情况下加载 URL
Loading URL without webview
如何在不使用 WebView 的情况下加载 URL,因为我的 class 没有可视化显示,它只是 .java 文件并且没有 .xml 文件res/layout 文件夹
我只想加载 URL,而不是显示或其他内容。我会用它来发送这样的信息。
private void sendRegistrationToServer(String token) {
//Code here
//Load("mywebsite.com/register.php?token="+token)
}
我尝试搜索但没有找到解决此问题的方法。
谢谢你:)
您可以使用HttpURLConnection
URL url = new URL("http://example.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
如何在不使用 WebView 的情况下加载 URL,因为我的 class 没有可视化显示,它只是 .java 文件并且没有 .xml 文件res/layout 文件夹
我只想加载 URL,而不是显示或其他内容。我会用它来发送这样的信息。
private void sendRegistrationToServer(String token) {
//Code here
//Load("mywebsite.com/register.php?token="+token)
}
我尝试搜索但没有找到解决此问题的方法。
谢谢你:)
您可以使用HttpURLConnection
URL url = new URL("http://example.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");