Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid, sending and recieving info from server
    primarykey
    data
    text
    <p>I'm working on an android app that has to send and receive information from a 3rd party server. I'm not experienced at this at all, so bear with me if I give too much/too little/not the right kind of information at first.</p> <p>The API that was provided to send information has the format </p> <pre><code>https://methodurl.com/username=user&amp;password=pass&amp;key=key&amp;info=infotosend </code></pre> <p>When I put this URL into my desktops browser, it returns a string, which I'm also trying to get. At least, I'm assuming all it returns is a string, since if I look at the page source, there is just a string, such as "200 OK" or "401 Unauthorized".</p> <p>The code I'm using is what I can glean from the web what I'm supposed to use. Unfortunately, for all I know, I'm writing code to do something very different than what I want. I've never written code to interact with a server before, so this is all new to me.</p> <p>Here's my code:</p> <pre><code>TextView urlView = (TextView)findViewById(R.id.url_view); HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(siteToSubmit); ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler(); try { String serverResponse = client.execute(request, responseHandler); urlView.setText(serverResponse); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>Logcat in eclipse (when app is running on the emulator) is</p> <pre><code>java.net.UnknownHostException </code></pre> <p>The way I understand the code to be working is I'm creating a client that will execute on a url (like would happen when I hit enter in the URL bar on a browser), a request for that client to execute on, and a handler to receive the response from the server, which is set to be recieved as a string. I am then trying to set that string as the text in a TextView to verify that I am getting the proper response. Right now, I just get the log error, and urlView does not change. Any ideas why? Am I understanding the process correctly?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload