Hi guys i am facing the outofmemory error while navigating between two page which has 2 Gallery controls(Image Gallery) each with some more additional details to fill out the profile informations. In first page we can view the profile details and we move to another page to edit the details and from there we can click on the cancel button to return back to the first page. So when clicking the edit and cancel buttons continuously the profile edit page opens and closed. While repeating the same process for some time, then the applications starts running through outofmemory and at one stage application fails to load the page due to insufficient internal memory. I am checking out for the possible solution to overcome this issue. Any advice or comments would be appreciated. Hoping for better response. Thanks in Advance.
Below is my Code:
edit_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//startActivity(new Intent(ProfileView.this, ProfileEdit.class));
startActivity(new Intent(ProfileView.this, ProfileEditLatest.class));
}
});
Below is getView method of gallery adapter:
public View getView(int position, View convertView, ViewGroup parent) {
/*if (position>data.length || position<0) {
return null;
}*/
View vi=convertView;
ImageView image;
if(convertView==null){
vi = inflater.inflate(R.layout.gridview_single, null);
//TextView text=(TextView)vi.findViewById(R.id.text);;
image=(ImageView)vi.findViewById(R.id.image);
final float scale = activity.getResources().getDisplayMetrics().density;
//int pixels = (int) (100 * scale + 0.5f);
int pixels = (int) (100 * scale + 0.5f);
//i.setLayoutParams(new Gallery.LayoutParams(100, 100));
//image.setLayoutParams(new Gallery.LayoutParams(pixels, pixels));
image.setLayoutParams(new RelativeLayout.LayoutParams(pixels,pixels));
//image.setLayoutParams(new LayoutParams(100,100));
//text.setText("item "+position);
}
else{
image=(ImageView)convertView;
}
try{
vi.setTag(data[position]);
imageLoader.DisplayImage(data[position], activity, image);
}
catch (ArrayIndexOutOfBoundsException e) {
// TODO: handle exception
}
return vi;
}
In above one i have used the lazy loading implemented which is available at URL
And in my Profile edit page i have a bitmap object declared as static which is used while uploading some new images into the gallery.
Hope the above details would be helpful for finding the solution to the problem.