Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 加载不带webview的URL_Java_Android_Httpurlconnection - Fatal编程技术网

Java 加载不带webview的URL

Java 加载不带webview的URL,java,android,httpurlconnection,Java,Android,Httpurlconnection,因为我的类没有可视化显示,它只是.java文件,在res/layout文件夹中没有.xml文件,所以我如何在不使用WebView的情况下加载URL 我只想加载URL,而不是显示什么。我会用它来发送这样的信息 private void sendRegistrationToServer(String token) { //Code here //Load("mywebsite.com/register.php?token="+token) } 我试图搜索,但没有找到解决这个问题的方

因为我的类没有可视化显示,它只是.java文件,在res/layout文件夹中没有.xml文件,所以我如何在不使用WebView的情况下加载URL

我只想加载URL,而不是显示什么。我会用它来发送这样的信息

private void sendRegistrationToServer(String token) {
    //Code here
    //Load("mywebsite.com/register.php?token="+token)
}
我试图搜索,但没有找到解决这个问题的方法

谢谢你:)

你可以用

你可以用

URL url = new URL("http://example.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");