>
> package www.ssshop.com;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.net.HttpURLConnection;
> import java.net.URL;
> import java.net.URLConnection;
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.parsers.ParserConfigurationException;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element; 
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
> import org.xml.sax.SAXException;
> import android.app.Activity;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.os.Bundle;
> import android.widget.ImageView;
> import android.widget.TextView;
> import android.widget.Toast;
> public class Http_connection extends Activity
> {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         
>         Bitmap bitmap = 
> DownloadImage("http://img.kaskus.us/banner/kaspay-banner.png";);
>         ImageView img = (ImageView) findViewById(R.id.img);
>         img.setImageBitmap(bitmap);
>         
>      }
>            
>     private InputStream OpenHttpConnection(String urlString) 
>     throws IOException
>     {
>         InputStream in = null;
>         int response = -1;
>                
>         URL url = new URL(urlString); 
>         URLConnection conn = url.openConnection();
>                  
>         if (!(conn instanceof HttpURLConnection))                     
>             throw new IOException("Not an HTTP connection");
>         
>         try{
>             HttpURLConnection httpConn = (HttpURLConnection) conn;
>             httpConn.setAllowUserInteraction(false);
>             httpConn.setInstanceFollowRedirects(true);
>             httpConn.setRequestMethod("GET");
>             httpConn.connect(); 
>             response = httpConn.getResponseCode();                 
>             if (response == HttpURLConnection.HTTP_OK) {
>                 in = httpConn.getInputStream();                           
>       
>             }                     
>         }
>         catch (Exception ex)
>         {
>             throw new IOException("Error connecting");            
>         }
>         return in;     
>     }
>     
>     private Bitmap DownloadImage(String URL)
>     {        
>         Bitmap bitmap = null;
>         InputStream in = null;        
>         try {
>             in = OpenHttpConnection(URL);
>             bitmap = BitmapFactory.decodeStream(in);
>             in.close();
>         } catch (IOException e1) {
>             // TODO Auto-generated catch block
>             e1.printStackTrace();
>         }
>         return bitmap;                
>     }
> }


when i try run those code at ICS API 15 it shows me nothing. but when i 
change the project to API 7 (Eclair) and run it, it show me the result.
is there any different between Eclair and ICS code?

-- 
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

Reply via email to