download image and show in activity in android
<p>I am having urls of images.
I am creating .JPEG files of it and saving in a directory of SD card.</p>

<p>After downloading all images (creating bitmaps and compressing in JPEG), i am calling another intent, which is supposed to show all images downloaded in that directory.</p>

<p>but I am seeing blank.</p>

<p>I cheecked DDMS, and found jpeg of correct sizes have got downloaded in my desired directory. But my intent is not showing.</p>

<p>To my surprise, when I close emulator , restart it, re run program with another set of image links, now my intent is showing previously downloaded images ! (not the images which r downloaded in this run of program).</p>

<p>Following is code i use for showing downloaded images:
Can anybody help me with this ?</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.imagechooser);


        Bundle bundle = this.getIntent().getExtras();
        thumbNailsLnkdhs = (LinkedHashSet&lt;String&gt;) bundle.getSerializable("keyThumbNails");

         Toast.makeText(getApplicationContext(),
                 "ThumbNailsLnkdhs size in new intent: "+thumbNailsLnkdhs.size(), Toast.LENGTH_LONG).show();

        final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID };
        final String orderBy = MediaStore.Images.Media._ID;


        Cursor imagecursor=managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                columns, 
                    MediaStore.Images.Media.DATA + " like ? ",
                    new String[] {"%myDesiredDirectory%"},  
                    null);

        Log.d(LOGGER, "cursor made");
        int colcount=imagecursor.getColumnCount();
        //.d(LOGGER, "cursor column count is: "+colcount);

        int count =imagecursor.getCount();
        //Log.d(LOGGER, "count is: "+count);

        String colnAME=imagecursor.getColumnName(0);
        //Log.d(LOGGER, "COL NAME FOR 0TH COLUMN="+colnAME);
        String colnAME_1=imagecursor.getColumnName(1);
        //Log.d(LOGGER, "COL NAME FOR 1st COLUMN="+colnAME_1);


        int image_column_index = imagecursor.getColumnIndex(imagecursor.getColumnName(1));
        //Log.d(LOGGER, "image_column_index="+image_column_index);

        //Log.d(LOGGER, "ThumbNailsLnkdhs size: "+ThumbNailsLnkdhs.size());

        //int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID);


        this.count = imagecursor.getCount();
        //Log.d(LOGGER, "this.count="+this.count);

        this.thumbnails = new Bitmap[this.count];
        this.arrPath = new String[this.count];
        this.thumbnailsselection = new boolean[this.count];

        for (int i = 0; i &lt; this.count; i++) {
            imagecursor.moveToPosition(i);
            int id = imagecursor.getInt(image_column_index);
            int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
            //Log.d(LOGGER, "dataColumnIndex="+dataColumnIndex);

            thumbnails[i] = MediaStore.Images.Thumbnails.getThumbnail(
                    getApplicationContext().getContentResolver(), id,
                    MediaStore.Images.Thumbnails.MICRO_KIND, null);

            arrPath[i]= imagecursor.getString(dataColumnIndex);
        }
        GridView imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
        imageAdapter = new ImageAdapter();
        imagegrid.setAdapter(imageAdapter);
        imagecursor.close();
    }
</code></pre>

<p>ok, so as per suggestion of below ansr,
I found I need to insert image  in gallery after I create its physical file.</p>

<p>I tried </p>

<pre><code>MediaStore.Images.Media.insertImage(getContentResolver(), bitmapimage,
imgname+ ".jpg Card Image", "imgDescription"
+ ".jpg Card Image");
</code></pre>

<p>but couldnt use getcontentresolver as im in a class which downloads,creates physical file and not inn activity.</p>

<p>So I tried </p>

<pre><code>sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
                +Environment.getExternalStorageDirectory()
        + "/myDesiredDirectory/")))
</code></pre>

<p>in my activity which displays previously downloaded images ... but it didnt helped me to show newly downloaded images... 
 so tried </p>

<pre><code>  sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"

                + Environment.getExternalStorageDirectory()+)));

    this also not showing new images :(
</code></pre>

<p>Can anyone help me with this ?</p>
