Problem in Using imageview

Put your problem here if it does not fit any of the other categories.

Problem in Using imageview

Postby NithinG » Wed Apr 30, 2008 1:01 pm

Hi all,

I hope every one of you having nice time.

I am having a problem in viewing image which is an image view. The code which i have used is given below.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. URL u;
  3.  
  4.         HttpURLConnection httpConn;
  5.  
  6.                         try {
  7.  
  8.                         u = new URL ("http://192.168.157.35:8080/myown/image.do");
  9.  
  10.                        
  11.  
  12.                         httpConn = ( HttpURLConnection )  u.openConnection (  );
  13.  
  14.                         httpConn.setRequestMethod ( "GET" ) ;
  15.  
  16.                 httpConn.connect (  ) ;
  17.  
  18.                 httpConn.getInputStream();
  19.  
  20.                 Bitmap bitmap1 = BitmapFactory.decodeStream(httpConn.getInputStream());
  21.  
  22.         BitmapDrawable  drawable1 = new BitmapDrawable(bitmap1);
  23.  
  24.         ImageView imageView = new ImageView(this);
  25.  
  26.         imageView.setImageDrawable(drawable1);
  27.  
  28.         imageView.setAdjustViewBounds(true);
  29.  
  30.         imageView.setPadding(200, 10, 0,300);
  31.  
  32.         addContentView(imageView,
  33.  
  34.                                new LinearLayout.LayoutParams(
  35.  
  36.                                            LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
  37.  
  38.                 } catch (MalformedURLException e) {
  39.  
  40.                         Log.e("Exception",""+e.toString());
  41.  
  42.                 }
  43.  
  44.                 catch (IOException e) {
  45.  
  46.                         Log.e("Exception",""+e.toString());
  47.  
  48.                 }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


in one of my friends system i have tried and its working, but when i tried in my system, its not working...

Its been stucked for some time and atlast giving ConnectionException....
Can anyone tell me, is there any settings i have to make to view this image on the emulator.
I tried a lot and im not able to figure it out.

Have a good time.
Thanks and regards,

NithinG
NithinG
Developer
Developer
 
Posts: 36
Joined: Wed Feb 27, 2008 6:24 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests