加载没有Webview的URL [英] Loading URL without webview
本文介绍了加载没有Webview的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用WebView的情况下加载URL,因为我的班级没有视觉显示,它只是.java文件,而res/layout文件夹中没有.xml文件
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
我只想加载URL,而不显示任何内容.我将用它来发送类似的信息.
I just want to load URL, not displaying or something. 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.
谢谢你:)
推荐答案
您可以使用 HttpURLConnection
URL url = new URL("http://example.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
这篇关于加载没有Webview的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文