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


Java ActivityManager.MemoryInfo方法代码示例

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


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

示例1: printMemoryInfo

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Print Memory info.
 */
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static ActivityManager.MemoryInfo printMemoryInfo(Context context) {
    ActivityManager.MemoryInfo mi = getMemoryInfo(context);

        StringBuilder sb = new StringBuilder();
        sb.append("_______  Memory :   ");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            sb.append("\ntotalMem        :").append(mi.totalMem);
        }
        sb.append("\navailMem        :").append(mi.availMem);
        sb.append("\nlowMemory       :").append(mi.lowMemory);
        sb.append("\nthreshold       :").append(mi.threshold);
        Log.i(TAG, sb.toString());

    return mi;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:20,代码来源:MemoryUtil.java

示例2: printMemoryInfo

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Print Memory info.
 */
@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static ActivityManager.MemoryInfo printMemoryInfo(Context context) {
    ActivityManager.MemoryInfo mi = getMemoryInfo(context);
    if (Log.isPrint) {
        StringBuilder sb = new StringBuilder();
        sb.append("_______  Memory :   ");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            sb.append("\ntotalMem        :").append(mi.totalMem);
        }
        sb.append("\navailMem        :").append(mi.availMem);
        sb.append("\nlowMemory       :").append(mi.lowMemory);
        sb.append("\nthreshold       :").append(mi.threshold);
        Log.i(TAG, sb.toString());
    }
    return mi;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:20,代码来源:MemoryUtil.java

示例3: 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:jqjm,项目名称:Liteframework,代码行数:11,代码来源:MemoryUtil.java

示例4: getAvailMemory

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

示例5: run

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public void run() {
    ActivityManager.MemoryInfo systemMemInfo = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(systemMemInfo);
    Debug.MemoryInfo processMemInfo = am.getProcessMemoryInfo(new int[]{Process.myPid()})[0];
    memInfo = new MemInfo(systemMemInfo, processMemInfo);
    notifyObservers();
    handler.postDelayed(memInfoQueryRunnable, interval);
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:10,代码来源:MemInfoDataModule.java

示例6: setupImageDisplay

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Draw bitmap image in app
 */
private void setupImageDisplay() {
    Bitmap rotateBitmap = getSampleBitmap(mCameraData, 500, 500);
    Bitmap cropBitmap = RotateBitmap(rotateBitmap, 90);
    rotateBitmap.recycle();
    mCameraBitmap = Bitmap.createBitmap(cropBitmap, cropBitmap.getWidth()/4, cropBitmap.getHeight()/2 - cropBitmap.getWidth()/4,
            cropBitmap.getWidth()/2, cropBitmap.getWidth()/2);
    cropBitmap.recycle();
    mCameraBitmap = getResizedBitmap(mCameraBitmap, 250, 250);
    ActivityManager.MemoryInfo memoryInfo = getAvailableMemory();
    Log.i(TAG, " memoryInfo.availMem " + memoryInfo.availMem + "\n" );
    Log.i(TAG, " memoryInfo.lowMemory " + memoryInfo.lowMemory + "\n" );
    Log.i(TAG, " memoryInfo.threshold " + memoryInfo.threshold + "\n" );

    Drawable drawable = new BitmapDrawable(getResources(), mCameraBitmap);

    if(mCameraImage.getDrawable() != null) ((BitmapDrawable)mCameraImage.getDrawable()).getBitmap().recycle();

    mCameraImage.setImageDrawable(drawable);
    mCamera.stopPreview();
    mCameraImage.setVisibility(View.VISIBLE);
    mCameraLayer.setVisibility(View.INVISIBLE);
    mCameraPreview.setVisibility(View.INVISIBLE);
    mDoneImageButton.setEnabled(true);
    mCaptureImageButton.setText(edu.osu.siyang.smartform.R.string.recapture_image);
    mCaptureImageButton.setOnClickListener(mRecaptureImageButtonClickListener);
}
 
开发者ID:publiclab,项目名称:SmART-Form,代码行数:30,代码来源:CameraActivity.java

示例7: getAvailMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
public static long getAvailMemory(Context context){
  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);// 将获取的内存大小规格化
  WXLogUtils.w("app AvailMemory ---->>>"+mi.availMem/(1024*1024));
  return mi.availMem/(1024*1024);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:10,代码来源:WXUtils.java

示例8: 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:jeasinlee,项目名称:AndroidBasicLibs,代码行数:12,代码来源:MemoryUtil.java

示例9: getAvailMemorySize

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 获取可用的内存大小(in k)
 *
 * @param context
 * @return
 */
public static Long getAvailMemorySize(Context context) {
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);
    return mi != null ? mi.availMem : null;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:13,代码来源:AndroidUtil.java

示例10: getmem_UNUSED

import android.app.ActivityManager; //导入方法依赖的package包/类
public static long getmem_UNUSED(Context mContext) {
    long MEM_UNUSED;
    // 得到ActivityManager
    ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);	
    // 创建ActivityManager.MemoryInfo对象          
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    // 取得剩余的内存空间        
    MEM_UNUSED = mi.availMem/1048576;
    return MEM_UNUSED;
}
 
开发者ID:januslo,项目名称:react-native-sunmi-inner-printer,代码行数:12,代码来源:MemInfo.java

示例11: getAvailMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 获取设备的可用内存
 *
 * @return
 */
public long getAvailMemory() {
    ActivityManager am = (ActivityManager) UtilManager.getContext().getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    return mi.availMem;
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:12,代码来源:DeviceInfo.java

示例12: 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

示例13: getAvailableMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Get available memory
 *
 * @param context
 * @return
 */
public static String getAvailableMemory(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    am.getMemoryInfo(mi);
    return Formatter.formatFileSize(context, mi.availMem);
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:13,代码来源: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: isLowLowDevice

import android.app.ActivityManager; //导入方法依赖的package包/类
public static boolean isLowLowDevice() {
    boolean isLowMen = true;
    try {
        final ActivityManager.MemoryInfo memoryInfo = getMemoryInfo(RApplication.getApp());
        isLowMen = memoryInfo.totalMem < 1000 * 1000 * 1000 * 1.5f;
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (!isLollipop()) {
        return true;
    }
    return isLowMen;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:UIIViewImpl.java


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