简体   繁体   English

加载没有Webview的URL

[英]Loading URL without webview

How can I load a URL without using WebView because my class has not a visual display it's just .java file and dont have .xml file in res/layout folder 如何在不使用WebView的情况下加载URL,因为我的班级没有视觉显示,它只是.java文件,而res / layout文件夹中没有.xml文件

I just want to load URL, not displaying or something. 我只想加载URL,而不显示任何内容。 I will use it for sending information like that. 我将使用它来发送类似的信息。

private void sendRegistrationToServer(String token) {
    //Code here
    //Load("mywebsite.com/register.php?token="+token)
}

I tried searching but found nothing to solve this issue. 我尝试搜索,但没有找到解决此问题的方法。

Thank u :) 感谢你 :)

You can use HttpURLConnection 您可以使用HttpURLConnection

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM