本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);// 将获取的内存大小规格化
}
示例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);
}
示例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);
}
示例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);
}
示例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);// 将获取的内存大小规格化
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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;
}