当前位置: 首页>>代码示例>>Java>>正文


Java ActivityManager.getMemoryInfo方法代码示例

本文整理汇总了Java中android.app.ActivityManager.getMemoryInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityManager.getMemoryInfo方法的具体用法?Java ActivityManager.getMemoryInfo怎么用?Java ActivityManager.getMemoryInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.ActivityManager的用法示例。


在下文中一共展示了ActivityManager.getMemoryInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRamCurrent

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Returns the current device RAM amount.
 */
static String getRamCurrent(Context context) {
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);
    return Long.toString(getTotalRAM() - (mi.availMem / 1048576L));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:CrashDetails.java

示例2: isLowMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
private static boolean isLowMemory(Context context) {
    if (null == context) {
        return false;
    }

    ActivityManager am = (ActivityManager)
                    context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(outInfo);

    return outInfo.lowMemory;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:13,代码来源:SqliteWrapper.java

示例3: getDeviceUsableMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 获取设备的可用内存大小
 *
 * @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));
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:15,代码来源:SystemTool.java

示例4: getDeviceUsableMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
     * Gets the available memory size of the device
     *
     * @param context context
     * @return Current memory size
     */
    public static int getDeviceUsableMemory(Context context) {
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
        am.getMemoryInfo(mi);
        // Returns the available memory for the current system
//        int size = (int) (mi.availMem / (1024 * 1024));
        int size1 = (int) (mi.availMem >> 20);
        return size1;
    }
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:16,代码来源:AppUtils.java

示例5: getAvailableMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Check available memory
 * @return
 */
private ActivityManager.MemoryInfo getAvailableMemory() {
    ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    return memoryInfo;
}
 
开发者ID:publiclab,项目名称:SmART-Form,代码行数:11,代码来源:CameraActivity.java

示例6: G

import android.app.ActivityManager; //导入方法依赖的package包/类
private static long G(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(ModelName
            .ACTIVITY);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    return memoryInfo.availMem;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:k.java

示例7: getTotalMemorySize

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 获取所有的内存大小(in k)
 *
 * @param context
 * @return
 */
@TargetApi(16)
public static Long getTotalMemorySize(Context context) {
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return mi != null ? mi.totalMem : null;
    } else {
        return null;
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:18,代码来源:AndroidUtil.java

示例8: onCreate

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_memory_info);
    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);

    TextView availableMemory = (TextView) findViewById(R.id.availableMemory);
    TextView percentAvailable = (TextView) findViewById(R.id.percentAvailable);
    TextView lowMemory = (TextView) findViewById(R.id.lowMemory);
    TextView threshold = (TextView) findViewById(R.id.threshold);
    TextView totalMemory = (TextView) findViewById(R.id.totalMemory);
    TextView etc = (TextView) findViewById(R.id.etc);

    StringBuilder sb = new StringBuilder();

    ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    double tmp = memoryInfo.availMem / 0x100000L;
    sb.append(tmp);
    sb.append(" MB");
    availableMemory.setText(sb.toString());

    tmp = memoryInfo.availMem / (double) memoryInfo.totalMem * 100.0;
    sb.setLength(0);
    sb.append(tmp);
    sb.append(" %");
    percentAvailable.setText(sb.toString());

    if (memoryInfo.lowMemory) {
        lowMemory.setText("Yes");
    }
    else {
        lowMemory.setText("No");
    }

    tmp = memoryInfo.threshold / 0x100000L;
    sb.setLength(0);
    sb.append(tmp);
    sb.append(" MB");
    threshold.setText(sb.toString());

    tmp = memoryInfo.totalMem / 0x100000L;
    sb.setLength(0);
    sb.append(tmp);
    sb.append(" MB");
    totalMemory.setText(sb.toString());

    ActivityManager.RunningAppProcessInfo runningAppProcessInfo = new ActivityManager.RunningAppProcessInfo();
    activityManager.getMyMemoryState(runningAppProcessInfo);

    sb.setLength(0);
    sb.append("PID: ");
    sb.append(runningAppProcessInfo.pid);
    sb.append("\n");
    sb.append("Importance: ");
    sb.append(runningAppProcessInfo.importance);
    sb.append("\n");
    sb.append("Last Trim Level: ");
    sb.append(runningAppProcessInfo.lastTrimLevel);
    sb.append("\n");
    sb.append("Importance Reason Code: ");
    sb.append(runningAppProcessInfo.importanceReasonCode);
    sb.append("\n");
    sb.append("LRU: ");
    sb.append(runningAppProcessInfo.lru);
    sb.append("\n");

    etc.setText(sb.toString());





}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:75,代码来源:MemoryInfoActivity.java

示例9: isLowMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isLowMemory() {
    ActivityManager activityManager = (ActivityManager)context.getSystemService(ACTIVITY_SERVICE);
    if (activityManager != null) {
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        activityManager.getMemoryInfo(memoryInfo);
        return memoryInfo.lowMemory;
    } else {
        return true;
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:11,代码来源:SkiaPooledImageRegionDecoder.java

示例10: getMemoryInfo

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Get memory info of device.
 */
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static ActivityManager.MemoryInfo getMemoryInfo(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    return mi;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:11,代码来源:MemoryUtil.java

示例11: getAvailMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
private static long getAvailMemory() {
	ActivityManager am = (ActivityManager) NimUIKit.getContext()
			.getSystemService(Context.ACTIVITY_SERVICE);
	ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
	am.getMemoryInfo(mi);
	return mi.availMem;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:8,代码来源:CrashSnapshot.java

示例12: L

import android.app.ActivityManager; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:l.java

示例13: getAvailMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Get available memory info.
 */
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static String getAvailMemory(Context context) {// 获取android当前可用内存大小
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    // mi.availMem; 当前系统的可用内存
    return Formatter.formatFileSize(context, mi.availMem);// 将获取的内存大小规格化
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:12,代码来源:MemoryUtil.java

示例14: getAllMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Get all memory
 *
 * @param context
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static String getAllMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    return Formatter.formatFileSize(context, mi.totalMem);
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:14,代码来源:MemoryCache.java

示例15: getAvailableMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
static public int getAvailableMemory(Context context)
{
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);
    Log.d(LoadOSService.class.getName(),"current available memory KB is:"+mi.availMem/1024);

    return (int)mi.availMem;
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:10,代码来源:LoadOSService.java


注:本文中的android.app.ActivityManager.getMemoryInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。