Code example for ActivityManager

Methods: getMemoryInfo

0
 
      if (!cache_dir.exists())
         cache_dir.mkdirs();
      MemoryInfo mi = new MemoryInfo();
      ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Activity.ACTIVITY_SERVICE);
      activityManager.getMemoryInfo(mi);
      long availableMegs = mi.availMem / 1048576L;
 
      if (availableMegs < 100) // if we are running so low
         use_mem_cache = false;
      ImageLoaderConfiguration.Builder cfg_builder = new ImageLoaderConfiguration.Builder(ctx);
      cfg_builder.threadPoolSize(5);
      cfg_builder.discCache(new UnlimitedDiscCache(cache_dir));
      cfg_builder.defaultDisplayImageOptions(DisplayImageOptions.createSimple());
      if (use_mem_cache)
         cfg_builder.memoryCache(new UsingFreqLimitedMemoryCache(1000000));  // use 1/3 of the mem for img caching
      cfg_builder.defaultDisplayImageOptions(options);
      return cfg_builder.build();
 
   }