Code example for ActivityManager

Methods: getMemoryClass

0
   * result is used for the lifetime of the game. 
   */ 
  protected Bitmap.Config preferredBitmapConfig() { 
    ActivityManager activityManager = (ActivityManager) 
      getApplication().getSystemService(Context.ACTIVITY_SERVICE); 
    int memoryClass = activityManager.getMemoryClass(); 
    int format = getWindowManager().getDefaultDisplay().getPixelFormat(); 
    // for low memory devices (like the HTC Magic), prefer 16-bit bitmaps 
    return (format == PixelFormat.RGBA_4444 || memoryClass <= 16) ? 
      Bitmap.Config.ARGB_4444 : Bitmap.Config.ARGB_8888; 
  } 
 
  protected float scaleFactor() { 
    return 1; // TODO: determine scale factor automatically? 
  } 
 
  /** Configures the maximum simultaneous sounds that may be played back. */ 
  protected int maxSimultaneousSounds() { 
    return 8; 
  }