本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}