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.
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 Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to