Reputation: 373
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?
Upvotes: 2
Views: 2016
Reputation: 3153
This is how I do URL requests in Android:
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;
}
This will return whatever is at that URL and it will never open a browser. You can choose whatever you want to do with the InputStream.
Upvotes: 6