Here you can find the source of getApplicationMemoryClass(@Nonnull Context context)
Parameter | Description |
---|---|
context | The Context to retrieve the ActivityManager |
public static int getApplicationMemoryClass(@Nonnull Context context)
//package com.java2s; /*/* w w w . j a v a 2 s . c om*/ * Copyright 2013 Luluvise Ltd * Copyright 2013 Marco Salis - fast3r(at)gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import javax.annotation.Nonnull; import android.app.ActivityManager; import android.content.Context; public class Main { /** * Returns the upper memory usage limit in bytes for the current application * retrieved from {@link ActivityManager#getMemoryClass()}. Using a * percentage of this value is a reliable way to limit memory caches. * * @param context * The {@link Context} to retrieve the {@link ActivityManager} * @return The application memory class in bytes */ public static int getApplicationMemoryClass(@Nonnull Context context) { final ActivityManager manager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); return manager.getMemoryClass() * 1024 * 1024; // to bytes } }