est le code que je travaille sur:affichage android objet JSON LISTVIEW
private final static String SERVICE_URI = "http://restwebservice.com/test/Service.svc";
StringEntity entity;
String var;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
callWebService();
Button btn = (Button) findViewById (R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(MainActivity.this, Test.class);
startActivity(i);
}
});
}
public void callWebService() {
try {
// make web service connection
HttpPost request = new HttpPost(SERVICE_URI + "/TestApplication");
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
// Build JSON string
JSONStringer TestApp = new JSONStringer().object().key("id")
.value("1").key("name").value("manish").key("email")
.value("[email protected]").key("country")
.value("india").endObject();
entity = new StringEntity(TestApp.toString());
var = EntityUtils.toString(entity);
Log.d("****Parameter Input****", "Testing:" + TestApp);
request.setEntity(entity);
// Send request to WCF service
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
Log.d("WebInvoke", "Saving: " + response.getStatusLine().toString());
// Get the status of web service
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
// print status in log
String line = "";
while ((line = rd.readLine()) != null) {
Log.d("****Status Line***", "Webservice: " + line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Je veux les afficher sur un listview. Avez-vous des tutoriels pour me lancer? Je suis nouveau aux services Web. Merci.