Java 类android.support.v4.app.ActivityManagerCompat 实例源码

项目:anitrend-app    文件:ConfigModule.java   
/**
 * Lazily apply options to a {@link GlideBuilder} immediately before the Glide singleton is
 * created.
 * <p>
 * <p>
 * This method will be called once and only once per implementation.
 * </p>
 *
 * @param context An Application {@link Context}.
 * @param builder The {@link GlideBuilder} that will be used to create Glide.
 */
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    // Increasing cache & pool by 25% - default is 250MB
    int memoryCacheSize = (int) (1.25 * calculator.getMemoryCacheSize());
    int bitmapPoolSize = (int) (1.25 * calculator.getBitmapPoolSize());
    int storageCacheSize = 1024 * 1024 * 350;
    if(context.getExternalCacheDir() != null) {
        long total = context.getExternalCacheDir().getUsableSpace();
        storageCacheSize = (int) (total*0.14);
    }

    builder.setMemoryCache(new LruResourceCache(memoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(bitmapPoolSize));
    builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, storageCacheSize));
    builder.setDecodeFormat(ActivityManagerCompat.isLowRamDevice(activityManager) ?
            DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}
项目:okwallet    文件:CrashReporter.java   
public static void appendDeviceInfo(final Appendable report, final Context context) throws IOException {
    final Resources res = context.getResources();
    final android.content.res.Configuration config = res.getConfiguration();
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
            .getSystemService(Context.DEVICE_POLICY_SERVICE);

    report.append("Device Model: " + Build.MODEL + "\n");
    report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n");
    report.append("ABIs: ").append(Joiner.on(", ").skipNulls().join(Strings.emptyToNull(Build.CPU_ABI),
            Strings.emptyToNull(Build.CPU_ABI2))).append("\n");
    report.append("Board: " + Build.BOARD + "\n");
    report.append("Brand: " + Build.BRAND + "\n");
    report.append("Device: " + Build.DEVICE + "\n");
    report.append("Display: " + Build.DISPLAY + "\n");
    report.append("Finger Print: " + Build.FINGERPRINT + "\n");
    report.append("Host: " + Build.HOST + "\n");
    report.append("ID: " + Build.ID + "\n");
    report.append("Product: " + Build.PRODUCT + "\n");
    report.append("Tags: " + Build.TAGS + "\n");
    report.append("Time: " + Build.TIME + "\n");
    report.append("Type: " + Build.TYPE + "\n");
    report.append("User: " + Build.USER + "\n");
    report.append("Configuration: " + config + "\n");
    report.append("Screen Layout: size "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
    report.append("Display Metrics: " + res.getDisplayMetrics() + "\n");
    report.append("Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass()
            + (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n");
    report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
    report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
    report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.vm.version")).append("\n");
}
项目:cwac-mediarouter    文件:MediaRouter.java   
GlobalMediaRouter(Context applicationContext) {
    mApplicationContext = applicationContext;
    mDisplayManager = DisplayManagerCompat.getInstance(applicationContext);
    mLowRam = ActivityManagerCompat.isLowRamDevice(
            (ActivityManager)applicationContext.getSystemService(
                    Context.ACTIVITY_SERVICE));

    // Add the system media route provider for interoperating with
    // the framework media router.  This one is special and receives
    // synchronization messages from the media router.
    mSystemProvider = SystemMediaRouteProvider.obtain(applicationContext, this);
    addProvider(mSystemProvider);
}