im new on Android Code, I need this for connect to internet and READ a JSON text from ASPX (Visual .NET for Websites) and Deserialize but my app crash when load the unic layout.
The JSON of the website doesnt have Arrays, I need help please!
This is on the ActivityMain.Java:
TextView wid = (TextView) findViewById(R.id.wid);
TextView name = (TextView) findViewById(R.id.name);
TextView url = (TextView) findViewById(R.id.url);
String str = "";
JSONObject json = null;
HttpResponse response;
HttpClient myClient = new DefaultHttpClient();
HttpPost URL = new HttpPost("http://validafacturas.com/BuzonFacturas/Account/Loginmb.aspx");
try {
response = myClient.execute(URL);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try{
JSONArray jArray = new JSONArray(str);
json = jArray.getJSONObject(0);
wid.setText(json.getString("success"));
name.setText(json.getString("message"));
url.setText(json.getString("iduser"));
} catch ( JSONException e) {
e.printStackTrace();
}
}
- The error when i use the "Debug" on the Eclipse, I see a Break-Point on "HTTP Response" (red dot), I test this app on Emulator & Xperia Sola in a connection in wi-fi
- I put the Internet Permission on the Manifest
- Thanks by the URL for JSON, but I don't have any trouble to understand the JSON. Thanks any way