package com.example.helloandroid; import java.io.IOException; import java.io.InputStream;
import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.*; import org.apache.http.client.methods.*; import org.apache.http.impl.client.DefaultHttpClient; //import org.apache.http.util.EntityUtils; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { HttpClient hc = new DefaultHttpClient(); HttpGet get = new HttpGet("http://www.yahoo.com"); HttpResponse rp = hc.execute(get); if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { //String str = EntityUtils.toString(rp.getEntity()); InputStream is = rp.getEntity().getContent(); String str = is.toString(); TextView tv = new TextView(this); tv.setText(str); setContentView(tv); } else { System.out.println("halo,baby."); } }catch(IOException e){ return; } } } the above is my code. but it seems there are some problems here. I want to send the HTTP request to yahoo and get back the returned response and show it out. So, Anyone can give me some ideas on it? Thank you. Carmen Lau --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---