本文整理汇总了Java中android.app.ActivityManager.getLargeMemoryClass方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityManager.getLargeMemoryClass方法的具体用法?Java ActivityManager.getLargeMemoryClass怎么用?Java ActivityManager.getLargeMemoryClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.ActivityManager
的用法示例。
在下文中一共展示了ActivityManager.getLargeMemoryClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import android.app.ActivityManager; //导入方法依赖的package包/类
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_FINISH_LAUNCHERACTIVITY:
//跳转到MainActivity,并结束当前的LauncherActivity
Intent intent = new Intent(LaunchActivity.this, HomeActivity.class);
startActivity(intent);
ActivityManager activityManager =(ActivityManager)getApplication().getSystemService(Context.ACTIVITY_SERVICE);
int x1=activityManager.getMemoryClass();
int x2=activityManager.getLargeMemoryClass();
Log.d("限制内存大小",String.valueOf(x1));
Log.d("限制最大内存大小",String.valueOf(x2));
LaunchActivity.this.finish();
break;
default:
break;
}
}
示例2: 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);
}
示例3: logMemoryInfo
import android.app.ActivityManager; //导入方法依赖的package包/类
public static void logMemoryInfo(Activity aty) {
ActivityManager activityManager = (ActivityManager) aty.getSystemService(Context.ACTIVITY_SERVICE);
int memClass = activityManager.getMemoryClass(); // m unit
int largeMemoryClass = activityManager.getLargeMemoryClass(); // m unit
float totalMemory = Runtime.getRuntime().totalMemory() * 1.0f / (1024 * 1024);
float freeMemory = Runtime.getRuntime().freeMemory() * 1.0f / (1024 * 1024);
float maxMemory = Runtime.getRuntime().maxMemory() * 1.0f / (1024 * 1024);
LogUtil.i("device memClass:" + memClass + "m");
LogUtil.i("device largeMemoryClass:" + largeMemoryClass + "m");
LogUtil.i("app totalMemory:" + totalMemory + "m");
LogUtil.i("app freeMemory:" + freeMemory + "m");
LogUtil.i("app maxMemory:" + maxMemory + "m");
}
示例4: getLargeMemoryClass
import android.app.ActivityManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getLargeMemoryClass(ActivityManager am) {
return am.getLargeMemoryClass();
}
示例5: 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);
}
}
示例6: getLargeMemoryClass
import android.app.ActivityManager; //导入方法依赖的package包/类
@TargetApi(11)
private static int getLargeMemoryClass(ActivityManager am) {
return am.getLargeMemoryClass();
}
示例7: 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();
}