Sorry, can you provide the link to where you got this demo?

Thanks,
Justin
Android Team @ Google

On May 6, 3:10 am, "resbonus(USOON.net)" <[EMAIL PROTECTED]> wrote:
> Hi ,everyone.I am using http connection demo,the following is the
> code.In the eclipse debugging mode, I can't get the error
> message.Eclipse recommended me like this
>
> Evaluations must contain either an expression or a block of well-
> formed statements
>
> when the break point is set at line 80.The eclipse version is 3.3.2
>
> java code:
>
> import java.io.BufferedInputStream;
> import java.io.BufferedReader;
> import java.io.DataInputStream;
> import java.io.DataOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.net.HttpURLConnection;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.net.URLConnection;
>
> import android.app.Activity;
> import android.content.Resources;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.View;
> import android.widget.Button;
> import android.widget.ImageView;
> import android.widget.TextView;
>
> public class NetDemo extends Activity {
>         private Button ok;
>         private TextView tv1;
>         HttpURLConnection uc;
>         URL url;
>         private static final String ip = "code.google.com/android/images/
> logo_android.gif";
>         private static final String host = "";
>         private static final String path = "http://"; + ip + host;
>
>         ImageView view1;
>         InputStream is;
>         BufferedInputStream bis;
>
>         /** Called when the activity is first created. */
>         @Override
>         public void onCreate(Bundle icicle) {
>                 super.onCreate(icicle);
>                 setContentView(R.layout.main);
>
>                 tv1 = (TextView) this.findViewById(R.id.tv1);
>                 ok = (Button) this.findViewById(R.id.ok);
>                 view1 = (ImageView) findViewById(R.id.icon);
>
>                 /*
>                  * Resources res=this.getResources();
> res.getDrawable(R.drawable.icon);
>                  * Bitmap bm = BitmapFactory.decodeResource(res, 
> R.drawable.icon);
>                  * view1.setImageBitmap(bm);
>                  */
>                 ok.setOnClickListener(new View.OnClickListener() {
>                         public void onClick(View view) {
>                                 openConn();
>                                 sendRequest();
>                                 getRespones();
>                                 closeConn();
>                         }
>                 });
>         }
>
>         private void openConn() {
>                 try {
>                         url = new URL(path);
>                         uc = (HttpURLConnection) url.openConnection();
>                         uc.setDoInput(true);
>                 } catch (MalformedURLException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 } catch (IOException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>         }
>
>         private void sendRequest() {
>                 try {
>                         uc.connect();
>                 } catch (IOException e) {
>                         System.out.println(e.getMessage());
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 } catch (Exception e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>         }
>
>         private void getRespones() {
>                 try {
>                         is = uc.getInputStream();
>                         Log.d("lenght", "" + uc.getContentLength());
>                         tv1.setText(uc.getContentLength() + "");
>                         bis = new BufferedInputStream(is);
>                         Bitmap bm = BitmapFactory.decodeStream(bis);
>                         view1.setImageBitmap(bm);
>                 } catch (IOException e1) {
>                         // TODO Auto-generated catch block
>                         e1.printStackTrace();
>                 }
>         }
>
>         private void closeConn() {
>                 try {
>                         uc.disconnect();
>                         if (null != bis) {
>                                 bis.close();
>                         }
>                         if (null != is) {
>                                 is.close();
>                         }
>                 } catch (IOException e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>         }
>
> }
>
> R.java
>
> public final class R {
>     public static final class attr {
>     }
>     public static final class drawable {
>         public static final int icon=0x7f020000;
>     }
>     public static final class id {
>         public static final int confirm=0x7f050002;
>         public static final int description=0x7f050001;
>         public static final int email=0x7f050000;
>     }
>     public static final class layout {
>         public static final int main=0x7f030000;
>         public static final int user_reg=0x7f030001;
>     }
>     public static final class string {
>         public static final int app_name=0x7f040000;
>         public static final int confirm=0x7f040004;
>         public static final int description=0x7f040002;
>         public static final int edit_userinfo=0x7f040005;
>         public static final int email=0x7f040001;
>         public static final int menu_insert=0x7f040003;
>     }
>
> }
>
> main.xml
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>         androidrientation="vertical" android:layout_width="fill_parent"
>         android:layout_height="fill_parent">
>         <ImageView android:id="@+id/icon" android:layout_marginTop="4dip"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content" />.
>         <Button android:id="@+id/ok" android:text="OK"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content" />
>
>         <TextView android:id="@+id/tv1" android:layout_width="fill_parent"
>                 android:layout_height="wrap_content"
>                 android:text="Hello World, NetDemo" 
> android:scrollbars="vertical" />
> </LinearLayout>
>
> Any refrence would be thankful.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to