當前位置: 首頁>>代碼示例>>Java>>正文


Java MemoryInfo類代碼示例

本文整理匯總了Java中android.app.ActivityManager.MemoryInfo的典型用法代碼示例。如果您正苦於以下問題:Java MemoryInfo類的具體用法?Java MemoryInfo怎麽用?Java MemoryInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MemoryInfo類屬於android.app.ActivityManager包,在下文中一共展示了MemoryInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
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);
}
 
開發者ID:liaohuqiu,項目名稱:cube-sdk,代碼行數:23,代碼來源:SystemWatcher.java

示例2: getAvailableMemory

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
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;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:18,代碼來源:EnvironmentalData.java

示例3: execute

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
@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;
}
 
開發者ID:Ankama,項目名稱:phonegap-sysinfo,代碼行數:23,代碼來源:Sysinfo.java

示例4: getAvailableMem

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
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;
}
 
開發者ID:qauck,項目名稱:qsysinfo,代碼行數:20,代碼來源:WidgetProvider.java

示例5: getDeviceUsableMemory

import android.app.ActivityManager.MemoryInfo; //導入依賴的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

示例6: getDeviceUsableMemory

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
/**
 * 獲取設備的可用內存大小
 *
 * @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));
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:14,代碼來源:AppUtils.java

示例7: getSizeTotalRAM

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
@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;
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:30,代碼來源:StorageUtils.java

示例8: AndroidCompatibility

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
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();
}
 
開發者ID:RedTroop,項目名稱:Cubes_2,代碼行數:9,代碼來源:AndroidCompatibility.java

示例9: getDeviceUsableMemory

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
/**
 * 獲取設備的可用內存大小
 *
 * @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));
}
 
開發者ID:huashengzzz,項目名稱:SmartChart,代碼行數:15,代碼來源:AppUtils.java

示例10: GetSurplusMemory

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
public long GetSurplusMemory() {
	info = new ActivityManager.MemoryInfo();
	activityManager.getMemoryInfo(info);
	long MemorySize = info.availMem;
	MemorySurPlus = (float) MemorySize / 1024 / 1024;
	return MemorySize;
}
 
開發者ID:Evan-Galvin,項目名稱:FreeStreams-TVLauncher,代碼行數:8,代碼來源:EliminateMainActivity.java

示例11: G

import android.app.ActivityManager.MemoryInfo; //導入依賴的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

示例12: L

import android.app.ActivityManager.MemoryInfo; //導入依賴的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: AndroidCompatibility

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
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();
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:9,代碼來源:AndroidCompatibility.java

示例14: getTotalRam

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:MusalaSoft,項目名稱:atmosphere-service,代碼行數:12,代碼來源:AgentRequestHandler.java

示例15: getAvailSpace

import android.app.ActivityManager.MemoryInfo; //導入依賴的package包/類
/**
 * @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;
}
 
開發者ID:cckevincyh,項目名稱:mobilesafe,代碼行數:15,代碼來源:ProcessInfoProvider.java


注:本文中的android.app.ActivityManager.MemoryInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。