Hi,
I referred the below link:
http://www.memofy.com/memofy/show/1008ab7f2836ab7f01071c2dbfe138/outofmemory-exception-when-decoding-with-bitmapfactory

<http://www.memofy.com/memofy/show/1008ab7f2836ab7f01071c2dbfe138/outofmemory-exception-when-decoding-with-bitmapfactory>when
to recycle the bitmap,delow is my code:

public void getBitmap( String[] str)
{
     InputStream is =null;
try {
for(int x =0;x<str.length;x++)
{
URL myFileUrl =new URL(str[x]);
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
 is = conn.getInputStream();

 BitmapFactory.Options options = new BitmapFactory.Options();
 options.inTempStorage = new byte[16*1024];
orgImg = BitmapFactory.decodeStream(is);
al_bitmap.add(orgImg);
}
 } catch (IOException e) {
e.printStackTrace();
 }
 finally{
if(is!=null)
{
try {
is.close();
 } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
 }

public class ImageAdapter extends BaseAdapter {
     int mGalleryItemBackground;
     private Context mContext;
     private FileInputStream fis;
     private ImageView[] mImages;
     public ImageAdapter(Context c) {
      mContext = c;
      mImages = new ImageView[al_bitmap.size()];
     }
     public int getCount() {
     System.out.println("bitmap size "+al_bitmap.size());
         return al_bitmap.size();
     }

     public Object getItem(int position) {
         return position;
     }

     public long getItemId(int position) {
         return position;
     }

     public View getView(int position, View convertView, ViewGroup parent) {

      //Use this code if you want to load from resources

     ImageView img;
     if (convertView == null) {
img = new ImageView(mContext);
}
     LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.coverflow, parent, false);
img = (ImageView) view.findViewById(R.id.img);
 System.out.println(" albitmap "+"position   "+position+"
"+al_bitmap.get(position));
if(al_bitmap.get(position) ==null)
{
img.setImageResource(R.drawable.bee);
         img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
         TextView title = (TextView) view.findViewById(R.id.title);
title.setText(titles.get(position));
TextView descrition = (TextView) view.findViewById(R.id.description);
descrition.setText(subtitle.get(position));
         BitmapDrawable drawable = (BitmapDrawable) img.getDrawable();
         drawable.setAntiAlias(true);
}
else
{
   img.setImageBitmap(al_bitmap.get(position));
            img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
TextView title = (TextView) view.findViewById(R.id.title);
title.setText(titles.get(position));
TextView descrition = (TextView) view.findViewById(R.id.description);
descrition.setText(subtitle.get(position));
         BitmapDrawable drawable = (BitmapDrawable) img.getDrawable();
         drawable.setAntiAlias(true);
}
         return view;
     }

Please reply


>>

-- 
 Regards,
Vani Reddy

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