Java 类android.app.ActivityManager.MemoryInfo 实例源码

项目:cube-sdk    文件:SystemWatcher.java   
public void run() {
    mTimerTask = new TimerTask() {

        @Override
        public void run() {

            MemoryInfo mi = new MemoryInfo();
            ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Activity.ACTIVITY_SERVICE);
            activityManager.getMemoryInfo(mi);
            Runtime runtime = Runtime.getRuntime();
            String s = String.format("free:%s%% %sKB total:%sKB max:%sKB ", runtime.freeMemory() * 100f / runtime.totalMemory(), runtime.freeMemory(), runtime.totalMemory() / 1024,
                    runtime.maxMemory() / 1024);
            // s += String.format("native: free:%sKB total:%sKB max:%sKB", android.os.Debug.getNativeHeapFreeSize() / 1024, android.os.Debug.getNativeHeapAllocatedSize() / 1024,
            // android.os.Debug.getNativeHeapSize() / 1024);
            // s += String.format("| availMem:%sKB", mi.availMem / 1024);
            Log.d("memory", s);
        }
    };

    mTimer = new Timer();
    mTimer.schedule(mTimerTask, 1000, 1000);
}
项目:12306-android-Decompile    文件:EnvironmentalData.java   
public final long getAvailableMemory()
{
  try
  {
    ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
    ActivityManager localActivityManager = (ActivityManager)this._application.getApplicationContext().getSystemService("activity");
    if (localActivityManager != null)
      localActivityManager.getMemoryInfo(localMemoryInfo);
    long l = localMemoryInfo.availMem;
    return l;
  }
  catch (Exception localException)
  {
    LogInternal.logException(localException);
  }
  return 0L;
}
项目:phonegap-sysinfo    文件:Sysinfo.java   
@Override
public boolean execute(String action, JSONArray args, CallbackContext callback) {

    Activity activity = this.cordova.getActivity();
    ActivityManager m = (ActivityManager) activity.getSystemService(Activity.ACTIVITY_SERVICE);
    this.memoryInfo = new MemoryInfo();
    m.getMemoryInfo(this.memoryInfo);

    if (action.equals("getInfo")) {
        try {
            JSONObject r = new JSONObject();
            r.put("cpu", this.getCpuInfo());
            r.put("memory", this.getMemoryInfo());
            Log.d("OUTPUT", r.toString());
            callback.success(r);
        } catch (final Exception e) {
            callback.error(e.getMessage());
        }
    }

    return false;
}
项目:12306-android-Decompile    文件:EnvironmentalData.java   
public final long getAvailableMemory()
{
  try
  {
    ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
    ActivityManager localActivityManager = (ActivityManager)this._application.getApplicationContext().getSystemService("activity");
    if (localActivityManager != null)
      localActivityManager.getMemoryInfo(localMemoryInfo);
    long l = localMemoryInfo.availMem;
    return l;
  }
  catch (Exception localException)
  {
    LogInternal.logException(localException);
  }
  return 0L;
}
项目:qsysinfo    文件:WidgetProvider.java   
static long getAvailableMem( ActivityManager am )
{
    long mem = -1;

    try
    {
        MemoryInfo mi = new MemoryInfo( );
        am.getMemoryInfo( mi );
        mem = mi.availMem;
    }
    catch ( Exception e )
    {
        Log.d( EndTaskService.class.getName( ),
                e.getLocalizedMessage( ),
                e );
    }

    return mem;
}
项目:FriendBook    文件:SystemTool.java   
/**
 * 获取设备的可用内存大小
 *
 * @param cxt 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:MVVMFrames    文件:AppUtils.java   
/**
 * 获取设备的可用内存大小
 *
 * @param context 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:easyfilemanager    文件:StorageUtils.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
   private long getSizeTotalRAM(boolean isTotal) {
    long sizeInBytes = 1000;
    MemoryInfo mi = new MemoryInfo();
    activityManager.getMemoryInfo(mi);
    if(isTotal) {
        try { 
            if(Utils.hasJellyBean()){
                long totalMegs = mi.totalMem;
                sizeInBytes = totalMegs;
            }
            else{
                RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
                String load = reader.readLine();
                String[] totrm = load.split(" kB");
                String[] trm = totrm[0].split(" ");
                sizeInBytes=Long.parseLong(trm[trm.length-1]);
                sizeInBytes=sizeInBytes*1024;
                reader.close(); 
            }
        } 
        catch (Exception e) { }
    }
    else{
        long availableMegs = mi.availMem;
        sizeInBytes = availableMegs;
    }       
    return sizeInBytes;
}
项目:Cubes_2    文件:AndroidCompatibility.java   
protected AndroidCompatibility(AndroidLauncher androidLauncher) {
    super(androidLauncher, Application.ApplicationType.Android);
    this.androidLauncher = androidLauncher;
    modLoader = new AndroidModLoader(this);

    activityManager = (ActivityManager) androidLauncher.getSystemService(Activity.ACTIVITY_SERVICE);
    memoryInfo = new MemoryInfo();
}
项目:SmartChart    文件:AppUtils.java   
/**
 * 获取设备的可用内存大小
 *
 * @param context 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context context) {
    ActivityManager am = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:FreeStreams-TVLauncher    文件:EliminateMainActivity.java   
public long GetSurplusMemory() {
    info = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(info);
    long MemorySize = info.availMem;
    MemorySurPlus = (float) MemorySize / 1024 / 1024;
    return MemorySize;
}
项目:FireFiles    文件:StorageUtils.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
   private long getSizeTotalRAM(boolean isTotal) {
    long sizeInBytes = 1000;
    MemoryInfo mi = new MemoryInfo();
    activityManager.getMemoryInfo(mi);
    if(isTotal) {
        try { 
            if(Utils.hasJellyBean()){
                long totalMegs = mi.totalMem;
                sizeInBytes = totalMegs;
            }
            else{
                RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
                String load = reader.readLine();
                String[] totrm = load.split(" kB");
                String[] trm = totrm[0].split(" ");
                sizeInBytes=Long.parseLong(trm[trm.length-1]);
                sizeInBytes=sizeInBytes*1024;
                reader.close(); 
            }
        } 
        catch (Exception e) { }
    }
    else{
        long availableMegs = mi.availMem;
        sizeInBytes = availableMegs;
    }       
    return sizeInBytes;
}
项目:boohee_v5.6    文件:k.java   
private static long G(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(ModelName
            .ACTIVITY);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    return memoryInfo.availMem;
}
项目:boohee_v5.6    文件:l.java   
public static String L(Context context) {
    try {
        ActivityManager activityManager = (ActivityManager) context.getSystemService
                (ModelName.ACTIVITY);
        MemoryInfo memoryInfo = new MemoryInfo();
        activityManager.getMemoryInfo(memoryInfo);
        return String.valueOf(memoryInfo.availMem / 1000000) + "/" + String.valueOf(ay() /
                1000000);
    } catch (Throwable th) {
        th.printStackTrace();
        return null;
    }
}
项目:simple-share-android    文件:StorageUtils.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
   private long getSizeTotalRAM(boolean isTotal) {
    long sizeInBytes = 1000;
    MemoryInfo mi = new MemoryInfo();
    activityManager.getMemoryInfo(mi);
    if(isTotal) {
        try { 
            if(Utils.hasJellyBean()){
                long totalMegs = mi.totalMem;
                sizeInBytes = totalMegs;
            }
            else{
                RandomAccessFile reader = new RandomAccessFile("/proc/meminfo", "r");
                String load = reader.readLine();
                String[] totrm = load.split(" kB");
                String[] trm = totrm[0].split(" ");
                sizeInBytes=Long.parseLong(trm[trm.length-1]);
                sizeInBytes=sizeInBytes*1024;
                reader.close(); 
            }
        } 
        catch (Exception e) { }
    }
    else{
        long availableMegs = mi.availMem;
        sizeInBytes = availableMegs;
    }       
    return sizeInBytes;
}
项目:Cubes    文件:AndroidCompatibility.java   
protected AndroidCompatibility(AndroidLauncher androidLauncher) {
  super(androidLauncher, Application.ApplicationType.Android);
  this.androidLauncher = androidLauncher;
  modLoader = new AndroidModLoader(this);

  activityManager = (ActivityManager) androidLauncher.getSystemService(Activity.ACTIVITY_SERVICE);
  memoryInfo = new MemoryInfo();
}
项目:atmosphere-service    文件:AgentRequestHandler.java   
/**
 * Gets the total RAM the device has.
 *
 * @return the total RAM of the device.
 */
private int getTotalRam() {
    MemoryInfo memoryInfo = new MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(memoryInfo);
    return (int) (memoryInfo.totalMem / BYTES_TO_MB);
}
项目:mobilesafe    文件:ProcessInfoProvider.java   
/**
 * @param ctx   
 * @return ���ؿ��õ��ڴ���    bytes
 */
public static long getAvailSpace(Context ctx){
    //1,��ȡactivityManager
    ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
    //2,�����洢�����ڴ�Ķ���
    MemoryInfo memoryInfo = new MemoryInfo();
    //3,��memoryInfo����(�����ڴ�)ֵ
    am.getMemoryInfo(memoryInfo);
    //4,��ȡmemoryInfo����Ӧ�����ڴ��С
    return memoryInfo.availMem;
}
项目:pandroid    文件:SystemUtils.java   
private static long getRamSizeAvailable(Context context) {
    long ramSize = 0;
    ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo memInfo = new MemoryInfo();
    actManager.getMemoryInfo(memInfo);
    ramSize = memInfo.availMem / (1024 * 1024);
    return ramSize;
}
项目:MobilePhoneSafeProtector    文件:SystemInfoUtil.java   
/**
 * 获取可用的内存信息
 */
public static long getAvailMemory(Context context) {
    ActivityManager am = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    //获取内存大小
    MemoryInfo mInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mInfo);
    return mInfo.availMem;
}
项目:IMKBaseFrameworkLibrary    文件:DeviceUtil.java   
/** 获取可用运存大小 */
public static long getAvailMemory(Context context) {
    // 获取android当前可用内存大小
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);

    // mi.availMem; 当前系统的可用内存
    // return Formatter.formatFileSize(context, mi.availMem);// 将获取的内存大小规格化

    return mi.availMem / (1024 * 1024);
}
项目:MemoryCleaner    文件:AppUtils.java   
/**
 * 描述:获取可用内存.
 */
public static long getAvailMemory(Context context) {
    // 获取android当前可用内存大小
    ActivityManager activityManager
            = (ActivityManager) context.getSystemService(
            Context.ACTIVITY_SERVICE);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    // 当前系统可用内存 ,将获得的内存大小规格化
    return memoryInfo.availMem;
}
项目:MVPFrames    文件:AppUtils.java   
/**
 * 获取设备的可用内存大小
 *
 * @param context 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:LemonUtils    文件:AppUtils.java   
/**
 * 
 * 描述:获取可用内存.
 * 
 * @param context
 * @return
 */
public static long getAvailMemory(Context context) {
    // 获取android当前可用内存大小
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    // 当前系统可用内存 ,将获得的内存大小规格化
    return memoryInfo.availMem;
}
项目:AppBajarLIB    文件:StorageUtils.java   
@SuppressLint("NewApi")
public static String getAvailableRamSize(Context con) {
    final ActivityManager actManager = (ActivityManager) con
            .getSystemService(Context.ACTIVITY_SERVICE);
    final MemoryInfo memInfo = new ActivityManager.MemoryInfo();
    actManager.getMemoryInfo(memInfo);
    final long totalMemory = memInfo.totalMem;
    return formatSize(totalMemory);
}
项目:fast-dev-library    文件:AbAppUtil.java   
/**
    * 
    * 描述:获取可用内存.
    * @param context
    * @return
    */
public static long getAvailMemory(Context context){  
       //获取android当前可用内存大小  
       ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);  
       MemoryInfo memoryInfo = new MemoryInfo();  
       activityManager.getMemoryInfo(memoryInfo);  
       //当前系统可用内存 ,将获得的内存大小规格化  
       return memoryInfo.availMem;  
   }
项目:MyScse-Client    文件:AppUtil.java   
/**
 * 获取设备的可用内存大小
 *
 * @param context 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context context) {
    ActivityManager am = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:EntboostIM    文件:PhoneInfo.java   
/**
 * get free memory of phone, in M
 * 
 * @param context
 * @return
 */
public static long getFreeMem(Context context) {
    ActivityManager manager = (ActivityManager) context
            .getSystemService(Activity.ACTIVITY_SERVICE);
    MemoryInfo info = new MemoryInfo();
    manager.getMemoryInfo(info);
    long free = info.availMem / 1024 / 1024;
    return free;
}
项目:VideoMeeting    文件:SystemUtils.java   
/**
 * 获取设备的可用内存大小
 * 
 * @param cxt
 *            应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:eshow-android    文件:AbAppUtil.java   
/**
    * 
    * 描述:获取可用内存.
    * @param context
    * @return
    */
public static long getAvailMemory(Context context){  
       //获取android当前可用内存大小  
       ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);  
       MemoryInfo memoryInfo = new MemoryInfo();  
       activityManager.getMemoryInfo(memoryInfo);  
       //当前系统可用内存 ,将获得的内存大小规格化  
       return memoryInfo.availMem;  
   }
项目:PhoneMate    文件:AppUtil.java   
/**
 * 描述:获取可用内存.
 *
 * @param context
 * @return
 */
public static long getAvailMemory(Context context) {
    // 获取android当前可用内存大小
    ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    // 当前系统可用内存 ,将获得的内存大小规格化
    return memoryInfo.availMem;
}
项目:safety    文件:SystemUtils.java   
/**
 * ��ȡ�ֻ������ڴ�
 * @param context
 * @return
 */
public static long getAvailMem(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
    MemoryInfo outInfo = new MemoryInfo();
    am.getMemoryInfo(outInfo);
    return outInfo.availMem;
}
项目:TTMemoryReleaser    文件:PhoneMemoryUtil.java   
/**
 * 得到当前可用内存大小
 * 
 * @param context
 * @return
 */
public static long getAvailMemory(Context context) {// 获取android当前可用内存大小
    ActivityManager am = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return mi.availMem;// 将获取的内存大小规格化
}
项目:BalloonPerformer    文件:PhoneMemoryUtil.java   
/**
 * 得到当前可用内存大小
 * 
 * @param context
 * @return
 */
public static long getAvailMemory(Context context) {// 获取android当前可用内存大小
    ActivityManager am = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return mi.availMem;// 将获取的内存大小规格化
}
项目:Lay-s    文件:SystemTool.java   
/**
 * 获取设备的可用内存大小
 *
 * @param cxt 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:Lulu    文件:SystemTool.java   
/**
 * 获取设备的可用内存大小
 *
 * @param cxt 应用上下文对象context
 * @return 当前内存大小
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    // 返回当前系统的可用内存
    return (int) (mi.availMem / (1024 * 1024));
}
项目:bVnc    文件:MainConfiguration.java   
protected void canvasStart() {
    if (selected == null) return;
    MemoryInfo info = Utils.getMemoryInfo(this);
    if (info.lowMemory)
        System.gc();
    start();
}
项目:android-tv-launcher    文件:EliminateMainActivity.java   
public long GetSurplusMemory() {
    info = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(info);
    long MemorySize = info.availMem;
    MemorySurPlus = (float) MemorySize / 1024 / 1024;
    return MemorySize;
}
项目:android-authenticator    文件:SystemTools.java   
/**
 * available memory size
 *
 * @param cxt context
 * @return memory size
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return (int) (mi.availMem / (1024 * 1024));
}
项目:android-authenticator    文件:SystemTools.java   
/**
 * available memory size
 *
 * @param cxt context
 * @return memory size
 */
public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt
            .getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);
    return (int) (mi.availMem / (1024 * 1024));
}