So I have an arduino with an Ethernet shield and I am currently controlling it using browser url commands eg "192.168.2.1/digital/2/1" (digital pin 2 goes high), i want to have an android button which requests that url without opening it in the browser.. is that possible and how would i do it?
问问题
1917 次
1 回答
6
这就是我在 Android 中执行 URL 请求的方式:
public InputStream download(String url) {
URL myFileURL = null;
InputStream is = null;
try {
myFileURL = new URL(url);
is = myFileURL.openStream();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return is;
}
这将返回该 URL 中的任何内容,并且永远不会打开浏览器。您可以选择任何您想要对 InputStream 执行的操作。
于 2012-04-27T20:27:57.843 回答