android - FragmentActivity allocates too much memory -


my main activity composed of gallery loads in cache 100mb photos , that's ok since more 30 bitmaps. got problem when clicking on 1 of images: i'm passing id in intent , getting bitmap parse load photo bigger when clicked.

public class imagefragment extends fragmentactivity {  imageview imageview; bitmap imagebitmap; public void oncreate(bundle savedinstancestate) {     final context mcontext = this;     super.oncreate(savedinstancestate);     setcontentview(r.layout.fragment_image);     final view v = new view(this.getapplicationcontext());      string objectid = getintent().getextras().getstring("objectid");     final imageview imageview= (imageview) findviewbyid(r.id.image_view_fragment);      parsequery<parseobject> queryfoto = new parsequery<parseobject>("photo");     queryfoto.whereequalto("objectid", objectid);     queryfoto.findinbackground(new findcallback<parseobject>() {         @override         public void done(list<parseobject> objects, parseexception e) {             if (e == null) {                 parsefile f = objects.get(0).getparsefile("photo");                 f.getdatainbackground(new getdatacallback() {                     @override                     public void done(byte[] data, parseexception e) {                          imagebitmap = bitmapfactory.decodebytearray(data, 0, data.length);                         //bitmaputil.scala function                         imageview.setimagebitmap(bitmaputil.scala(imagebitmap));                       }                     });                 } else { //this fuction check error                     check(e.getcode(), v, e.getmessage());                 }             }         });     } 

and scala function

public static bitmap scala(bitmap imagebitmap){         int w=imagebitmap.getwidth();         int h=imagebitmap.getheight();         int maxsize=gl10.gl_max_texture_size;         system.out.println("w="+w+" h="+h+" maxsize="+maxsize);         bitmap scaledbitmap=imagebitmap;      if (imagebitmap.getwidth() > gl10.gl_max_texture_size ) {          system.out.println("1");         float aspect_ratio = ((float) imagebitmap.getwidth()) / ((float) imagebitmap.getheight());          int wout=maxsize-1;         int hout= (int) (wout/aspect_ratio);         system.out.println("aspect_ratio"+aspect_ratio+" wout"+wout+" hout"+hout);         scaledbitmap = bitmap.createscaledbitmap(imagebitmap,(int)wout-1, (int)hout-1,false);      }      if(imagebitmap.getheight()>gl10.gl_max_texture_size){         system.out.println("2");         float aspect_ratio = ((float) imagebitmap.getwidth()) / ((float) imagebitmap.getheight());          int hout=maxsize-1;         int wout= (int) (aspect_ratio*hout);         system.out.println("aspect_ratio"+aspect_ratio+" wout"+wout+" hout"+hout);         scaledbitmap = bitmap.createscaledbitmap(imagebitmap,(int)wout-1, (int)hout-1,false);         return scaledbitmap;     }      return scaledbitmap;  } 

so problem allocates 60mb activity, , doesn't deallocate when pressed. photo 1mb , i've tried scale isn't working.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -