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


Java ActivityManager.getMemoryClass方法代码示例

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


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

示例1: isLowMemory

import android.app.ActivityManager; //导入方法依赖的package包/类
@TargetApi(VERSION_CODES.KITKAT)
public static boolean isLowMemory(Context context) {
  ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

  return (VERSION.SDK_INT >= VERSION_CODES.KITKAT && activityManager.isLowRamDevice()) ||
         activityManager.getMemoryClass() <= 64;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:Util.java

示例2: getInstance

import android.app.ActivityManager; //导入方法依赖的package包/类
public synchronized static ContactPictureCache getInstance(Context context) {
    if (sInstance == null) {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        sMemClass = activityManager.getMemoryClass();
        sInstance = new ContactPictureCache();
    }
    return sInstance;
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:9,代码来源:ContactPictureCache.java

示例3: getMaxSize

import android.app.ActivityManager; //导入方法依赖的package包/类
private static int getMaxSize(ActivityManager activityManager, float maxSizeMultiplier,
    float lowMemoryMaxSizeMultiplier) {
  final int memoryClassBytes = activityManager.getMemoryClass() * 1024 * 1024;
  final boolean isLowMemoryDevice = isLowMemoryDevice(activityManager);
  return Math.round(memoryClassBytes * (isLowMemoryDevice ? lowMemoryMaxSizeMultiplier
      : maxSizeMultiplier));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MemorySizeCalculator.java

示例4: calculateMemoryCacheSize

import android.app.ActivityManager; //导入方法依赖的package包/类
static int calculateMemoryCacheSize(Context context) {
  ActivityManager am = getService(context, ACTIVITY_SERVICE);
  boolean largeHeap = (context.getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0;
  int memoryClass = largeHeap ? am.getLargeMemoryClass() : am.getMemoryClass();
  // Target ~15% of the available heap.
  return (int) (1024L * 1024L * memoryClass / 7);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:Utils.java

示例5: createMemoryCache

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Creates default implementation of {@link MemoryCache} - {@link LruMemoryCache}<br />
 * Default cache size = 1/8 of available app memory.
 */
public static MemoryCache createMemoryCache(Context context, int memoryCacheSize) {
	if (memoryCacheSize == 0) {
		ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		int memoryClass = am.getMemoryClass();
		if (hasHoneycomb() && isLargeHeap(context)) {
			memoryClass = getLargeMemoryClass(am);
		}
		memoryCacheSize = 1024 * 1024 * memoryClass / 8;
	}
	return new LruMemoryCache(memoryCacheSize);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:DefaultConfigurationFactory.java

示例6: onCreate

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    if(!BuildConfig.DEBUG) {
        AnalyticsManager.intialize(getApplicationContext());
    }
    sInstance = this;
    final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final int memoryClassBytes = am.getMemoryClass() * 1024 * 1024;

    mRoots = new RootsCache(this);
    mRoots.updateAsync();

    mSAFManager = new SAFManager(this);

    mThumbnails = new ThumbnailCache(memoryClassBytes / 4);

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
    packageFilter.addDataScheme("package");
    registerReceiver(mCacheReceiver, packageFilter);

    final IntentFilter localeFilter = new IntentFilter();
    localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    registerReceiver(mCacheReceiver, localeFilter);

    isTelevision = Utils.isTelevision(this);
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:32,代码来源:DocumentsApplication.java

示例7: calculateCacheSize

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public int calculateCacheSize(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    int targetMemoryCacheSize = (int) (activityManager.getMemoryClass() * MAX_SIZE_MULTIPLIER * 1024);
    if (targetMemoryCacheSize >= MAX_SIZE){
        return MAX_SIZE;
    }
    return targetMemoryCacheSize;
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:10,代码来源:CacheType.java

示例8: createMemoryCache

import android.app.ActivityManager; //导入方法依赖的package包/类
public static MemoryCache createMemoryCache(Context context, int memoryCacheSize) {
    if (memoryCacheSize == 0) {
        ActivityManager am = (ActivityManager) context.getSystemService(ModelName.ACTIVITY);
        int memoryClass = am.getMemoryClass();
        if (hasHoneycomb() && isLargeHeap(context)) {
            memoryClass = getLargeMemoryClass(am);
        }
        memoryCacheSize = (1048576 * memoryClass) / 8;
    }
    return new LruMemoryCache(memoryCacheSize);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:DefaultConfigurationFactory.java

示例9: calculateCacheSize

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public int calculateCacheSize(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    int targetMemoryCacheSize = (int) (activityManager.getMemoryClass() * MAX_SIZE_MULTIPLIER * 1024);
    if (targetMemoryCacheSize >= MAX_SIZE) {
        return MAX_SIZE;
    }
    return targetMemoryCacheSize;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:10,代码来源:CacheType.java

示例10: onBaseInit

import android.app.ActivityManager; //导入方法依赖的package包/类
protected void onBaseInit() {
    isLowDevice = UIIViewImpl.isLowDevice();
    isHighDevice = UIIViewImpl.isHighDevice();

    try {
        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        memoryClass = manager.getMemoryClass();
        largeMemoryClass = manager.getLargeMemoryClass();
    } catch (Exception e) {

    }
    //96 256
    L.e("RApplication -> memoryClass:" + memoryClass + "MB largeMemoryClass:" + largeMemoryClass + "MB");

    Utils.init(this);

         /*sp持久化库*/
    Hawk.init(this)
            .build();

        /*崩溃异常处理*/
    RCrashHandler.init(this);

    SkinHelper.init(this);

        /*Realm数据库初始化*/
    //RRealm.init(this, "r_jcenter.realm", true);

        /*Facebook图片加载库, 必须*/
    //Fresco.initialize(this);

    onInit();

    new Thread() {
        @Override
        public void run() {
            Debug.logTimeStart("RApplication 异步初始化:onAsyncInit()");
            onAsyncInit();
            Debug.logTimeEnd("RApplication 异步初始化结束:onAsyncInit()");
        }
    }.start();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:43,代码来源:RApplication.java

示例11: init

import android.app.ActivityManager; //导入方法依赖的package包/类
@SuppressLint("NewApi")
    private void init() {
//        setWillNotCacheDrawing(true);
//        setDrawingCacheEnabled(false);
        
        mEmpty = true;

        // setup brush bitmaps
        final ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mMemClass = am.getLargeMemoryClass();
        } else {
            mMemClass = am.getMemoryClass();
        }
        mLowMem = (mMemClass <= 16);
        if (true||DEBUG) {
            Log.v(TAG, "Slate.init: memClass=" + mMemClass + (mLowMem ? " (LOW)" : ""));
        }

        final Resources res = getContext().getResources();

//        mCircleBits = BitmapFactory.decodeResource(res, R.drawable.circle_1bpp);
//        if (mCircleBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load circle bitmap"); }
//        mCircleBitsFrame = new Rect(0, 0, mCircleBits.getWidth(), mCircleBits.getHeight());

        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inPreferredConfig = Bitmap.Config.ALPHA_8;
        if (mLowMem) { // let's see how this works in practice
            opts.inSampleSize = 4;
        }
        mAirbrushBits = BitmapFactory.decodeResource(res, R.drawable.airbrush_light, opts);
        if (mAirbrushBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load airbrush bitmap"); }
        mAirbrushBitsFrame = new Rect(0, 0, mAirbrushBits.getWidth(), mAirbrushBits.getHeight());
        //Log.v(TAG, "airbrush: " + mAirbrushBitsFrame.right + "x" + mAirbrushBitsFrame.bottom);
        mFountainPenBits = BitmapFactory.decodeResource(res, R.drawable.fountainpen, opts);
        if (mFountainPenBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load fountainpen bitmap"); }
        mFountainPenBitsFrame = new Rect(0, 0, mFountainPenBits.getWidth(), mFountainPenBits.getHeight());

        // set up individual strokers for each pointer
        mStrokes = new MarkersPlotter[MAX_POINTERS]; // TODO: don't bother unless hasSystemFeature(MULTITOUCH_DISTINCT)
        for (int i=0; i<mStrokes.length; i++) {
            mStrokes[i] = new MarkersPlotter();
        }
        
        mPressureCooker = new PressureCooker(getContext());

        setFocusable(true);
        
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            if (HWLAYER) {
                setLayerType(View.LAYER_TYPE_HARDWARE, null);
            } else if (SWLAYER) {
                setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            } else {
                setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
        
        mWorkspacePaint = new Paint();
        mWorkspacePaint.setColor(0x40606060);

        mBlitPaint = new Paint();

        if (true) {
            mDebugPaints[0] = new Paint();
            mDebugPaints[0].setStyle(Style.STROKE);
            mDebugPaints[0].setStrokeWidth(2.0f);
            mDebugPaints[0].setARGB(255, 0, 255, 255);
            mDebugPaints[1] = new Paint(mDebugPaints[0]);
            mDebugPaints[1].setARGB(255, 255, 0, 128);
            mDebugPaints[2] = new Paint(mDebugPaints[0]);
            mDebugPaints[2].setARGB(255, 0, 255, 0);
            mDebugPaints[3] = new Paint(mDebugPaints[0]);
            mDebugPaints[3].setARGB(255, 30, 30, 255);
            mDebugPaints[4] = new Paint();
            mDebugPaints[4].setStyle(Style.FILL);
            mDebugPaints[4].setARGB(255, 128, 128, 128);
        }
    }
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:80,代码来源:Slate.java


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