this is what I use...
public String callWebPage(String URLstring, String parameters){
String s;
try {
URL updateURL = new URL(URLstring+parameters);
URLConnection conn = updateURL.openConnection();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
Log.e("SettingsDialog", "after the call to web");
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}
Log.e("SettingsDialog", "back from web page"+parameters);
/* Convert the Bytes read to a String. */
s = new String(baf.toByteArray());
Log.e("SettingsDialog", String.format("in callWebPage =
%s ",s));
return s;
} catch (Exception e) {
Log.e("SettingsDialog", "exception in callWebPage");
}
return "error";
}
I often find that the string parameters of the php script has errors.
It's worthwhile to run the php from a browser first
On Oct 25, 11:14 am, David Kebo <[email protected]> wrote:
> I am trying to call a URL for code.
> This URL is supposed to move a camera connected on the same network
>
> url = new URL("http://10.0.1.90/axis-cgi/com/ptz.cgi?
> camera=1&move=home");
> URLConnection cameraConnection = url.openConnection();
> cameraConnection.connect();
>
> I get no response when I run this code. Is this the right way to call
> a URL from an Android phone ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---