I'm trying to contact an API and get feedback. As part of my debugging, I want to make sure the response is being recorded, this should be an XML response.
Here's what I have:
Extension of the public class's HTTV activity [/ P>
Public Zero HTTPMethod () {HttpClient httpclient = New DefaultHttpClient () ; Http post httppost = new HTTP post ("http://site.com/api/"); Try {// Add Your Data List & lt; NameValuePair & gt; NameValuePairs = New ArrayList & lt; NameValuePair & gt; (2); NameValuePairs.add (new binarynamewallpayer ("APKI", "0d4e122d20")); NameValuePairs.add (New Basic Named Pair ("ip", "65.82.126.103")); Httppost.setEntity (new UrlEncodedFormEntity (nameValuePairs)); // Execute HTTP Post Request HTTP Response Response = httpclient.execute (httppost); } Capture (Client Protocol Extension E) {// Todo Auto-Generated Coke Block} Catch (IOException E) {// Too-Auto Auto Generated Cache Block} TextView MyTextView = (TextView) SearchVBIID (RaidMytextView); MyTextView.setText (response); }} I am trying to see the response that I get, though the variable response in the line
myTextView.setText (response) < / Code> is throwing an error:
the response can not be solved in a variable the actual response Is there a variable in type httpresponse? What is happening ...?
The scope of the response variable is only inside the try block
TextView MyTextView =
(TextView) Find VVBIID (R.D.me.teviewview); MyTextView.setText (response);
2) Define httprespaces try out side feedback. Edit: As the variant is specified when you define outside the attempt block, make sure to check blank to check NullPointerException . Read it
Comments
Post a Comment