title: How to get image from web service to android application?
body: <p>I am trying to load images from a server, according to their id number. Which would be the best method to retrive it from the webservice?</p>
  <pre><code>package com.crispsys;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.Bundle;
  import android.os.Handler;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class imageviewer extends Activity {
      /** Called when the activity is first created. */
      
      Bitmap image; 
      private TextView ordernumber;
       ImageView imageView;
       private Button butt;
       String Str=&quot;image&quot;,ordno;
       
      
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.imageviewerr);
          
           this.butt = (Button) this.findViewById(R.id.getbutt);
            this.imageView =(ImageView) findViewById(R.id.blodig);
            this.ordernumber=(TextView)this.findViewById(R.id.ordernotext);
            
            final Bundle getdata = getIntent().getExtras();
            
            if (getdata != null)    
            {
                ordno=getdata.getString(&quot;orono&quot;);
                ordernumber.setText(ordno);
            }
           
          
          this.butt.setOnClickListener(new View.OnClickListener() {
              
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  
                  
                  Toast.makeText(getApplicationContext(),&quot;loading&quot; , Toast.LENGTH_LONG).show();
                  
                        URL url = null;
                  
                  
                        try 
                        {
                          
                            url = new URL(&quot;http://www.cyberstudents.in/aaa/car.jpg&quot;);
                            
                        }
                        catch (MalformedURLException e) 
                        {
                            e.printStackTrace();
                        }
                        try {
                            image = BitmapFactory.decodeStream(url.openStream());
                           
                        } 
                        catch (IOException e) 
                        {
                            e.printStackTrace();
                        }
                  
                  imageView.setImageBitmap(image);
              }
          });
         
      }
  }
  </code></pre>
  <p>XML File:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:background=&quot;@drawable/cr_isp&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot; &gt;
  
      &lt;TableRow
          android:id=&quot;@+id/tableRow1&quot;
          android:layout_width=&quot;match_parent&quot;
          android:gravity=&quot;center&quot;
          android:paddingTop=&quot;20dp&quot;
          android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
              android:id=&quot;@+id/ordernotext&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textColor=&quot;#8B8682&quot;
              android:text=&quot;&quot; /&gt;
  
         
      &lt;/TableRow&gt; 
      
      &lt;TableRow
          android:id=&quot;@+id/tableRow1&quot;
          android:layout_width=&quot;match_parent&quot;
          android:gravity=&quot;center&quot;
          android:paddingTop=&quot;20dp&quot;
          android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;Button
              android:id=&quot;@+id/getbutt&quot;
              android:layout_width=&quot;210dp&quot;
              android:layout_height=&quot;40dp&quot;
              android:background=&quot;@drawable/bcbut&quot;
              android:textColor=&quot;#8B8682&quot;
              android:text=&quot;Get Block Dig&quot; /&gt;
          
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:id=&quot;@+id/tableRow2&quot;
          android:layout_width=&quot;match_parent&quot;
          android:gravity=&quot;center&quot;
          android:paddingTop=&quot;20dp&quot;
          android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;ImageView
              android:id=&quot;@+id/blodig&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:src=&quot;@drawable/ic_launcher&quot; /&gt;
  
      &lt;/TableRow&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>Tried with this code, but I could only work with small sized images. When I go for a big sized image, it doesn't work. It remains the same, I can't find any error. It is showing the same screen.</p>