Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>full example working ...i tried myself some days ago.. im sure it will help..</p> <pre><code>package com.imagedownloader; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.widget.ImageView; public class ImageDownloaderActivity 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://www.allindiaflorist.com/imgs/arrangemen4.jpg"); ImageView img =(ImageView)findViewById(R.id.imageView1); img.setImageBitmap(bitmap); } private Bitmap DownloadImage(String URL) { // TODO Auto-generated method stub Bitmap bitmap=null; InputStream in=null; try { in=OpenHttpConnection(URL); bitmap=BitmapFactory.decodeStream(in); in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bitmap; } private InputStream OpenHttpConnection(String stingurl) throws IOException { // TODO Auto-generated method stub InputStream in=null; int response=-1; URL url = new URL(stingurl); URLConnection conn=url.openConnection(); if(!(conn instanceof HttpURLConnection)) throw new IOException("not and http exception"); 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; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload