當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。