Example usage for android.app ActivityManager getMemoryClass

List of usage examples for android.app ActivityManager getMemoryClass

Introduction

In this page you can find the example usage for android.app ActivityManager getMemoryClass.

Prototype

public int getMemoryClass() 

Source Link

Document

Return the approximate per-application memory class of the current device.

Usage

From source file:info.awesomedevelopment.tvgrid.library.TVGridView.java

@SuppressWarnings("deprecation")
private void init(AttributeSet attrs) {
    ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    mCache = new LruCache<>(am.getMemoryClass() * 1024);

    mYSize = new ValueAnimator();
    mXSize = new ValueAnimator();
    mYLocation = new ValueAnimator();
    mXLocation = new ValueAnimator();

    mXSize.addUpdateListener(xSizeListener);
    mYSize.addUpdateListener(ySizeListener);
    mYLocation.addUpdateListener(yLocationListener);
    mXLocation.addUpdateListener(xLocationListener);

    mSelectorAnimationSet.playTogether(mXLocation, mYLocation, mXSize, mYSize);
    mSelectorAnimationSet.setInterpolator(new AccelerateDecelerateInterpolator());
    mSelectorAnimationSet.setDuration(ANIMATION_DURATION);

    TypedValue fillAlpha = new TypedValue();
    getResources().getValue(R.dimen.tvg_defFillAlpha, fillAlpha, true);

    TypedValue fillAlphaSelected = new TypedValue();
    getResources().getValue(R.dimen.tvg_defFillAlphaSelected, fillAlphaSelected, true);

    if (attrs != null) {
        TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.TVGridView, 0, 0);

        try {/*from   w w  w . j  ava  2  s  .  co  m*/
            //noinspection ResourceType
            mStrokePosition = a.getInteger(R.styleable.TVGridView_tvg_strokePosition, OUTSIDE);
            //noinspection ResourceType
            mSelectorPosition = a.getInteger(R.styleable.TVGridView_tvg_selectorPosition, OVER);
            //noinspection ResourceType
            mSelectorShape = a.getInteger(R.styleable.TVGridView_tvg_selectorShape, RECTANGLE);

            mAnimateSelectorChanges = a.getBoolean(R.styleable.TVGridView_tvg_animateSelectorChanges,
                    getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1);
            mIsFilled = a.getBoolean(R.styleable.TVGridView_tvg_filled,
                    getResources().getInteger(R.integer.tvg_defIsFilled) == 1);
            mFillAlpha = a.getFloat(R.styleable.TVGridView_tvg_fillAlpha, fillAlpha.getFloat());
            mFillAlphaSelected = a.getFloat(R.styleable.TVGridView_tvg_fillAlphaSelected,
                    fillAlphaSelected.getFloat());
            mFillColor = a.getColor(R.styleable.TVGridView_tvg_fillColor,
                    getResources().getColor(R.color.tvg_defFillColor));
            mFillColorSelected = a.getColor(R.styleable.TVGridView_tvg_fillColorSelected,
                    getResources().getColor(R.color.tvg_defFillColorSelected));
            mCornerRadiusX = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius,
                    getResources().getDimension(R.dimen.tvg_defCornerRadius));
            mCornerRadiusY = a.getDimension(R.styleable.TVGridView_tvg_cornerRadius,
                    getResources().getDimension(R.dimen.tvg_defCornerRadius));
            mStrokeWidth = a.getDimension(R.styleable.TVGridView_tvg_strokeWidth,
                    getResources().getDimension(R.dimen.tvg_defStrokeWidth));
            mStrokeColor = a.getColor(R.styleable.TVGridView_tvg_strokeColor,
                    getResources().getColor(R.color.tvg_defStrokeColor));
            mStrokeColorSelected = a.getColor(R.styleable.TVGridView_tvg_strokeColorSelected,
                    getResources().getColor(R.color.tvg_defStrokeColorSelected));
            mStrokeMarginLeft = a.getDimension(R.styleable.TVGridView_tvg_marginLeft,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft));
            mStrokeMarginTop = a.getDimension(R.styleable.TVGridView_tvg_marginTop,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginTop));
            mStrokeMarginRight = a.getDimension(R.styleable.TVGridView_tvg_marginRight,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginRight));
            mStrokeMarginBottom = a.getDimension(R.styleable.TVGridView_tvg_marginBottom,
                    getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom));
            mStrokeSpacingLeft = a.getDimension(R.styleable.TVGridView_tvg_spacingLeft,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft));
            mStrokeSpacingTop = a.getDimension(R.styleable.TVGridView_tvg_spacingTop,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop));
            mStrokeSpacingRight = a.getDimension(R.styleable.TVGridView_tvg_spacingRight,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight));
            mStrokeSpacingBottom = a.getDimension(R.styleable.TVGridView_tvg_spacingBottom,
                    getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom));
        } finally {
            a.recycle();
        }
    } else {
        mStrokePosition = OUTSIDE;
        mSelectorPosition = OVER;
        mSelectorShape = RECTANGLE;

        mAnimateSelectorChanges = getResources().getInteger(R.integer.tvg_defAnimateSelectorChanges) == 1;
        mIsFilled = getResources().getInteger(R.integer.tvg_defIsFilled) == 1;
        mFillAlpha = fillAlpha.getFloat();
        mFillAlphaSelected = fillAlphaSelected.getFloat();
        mFillColor = getResources().getColor(R.color.tvg_defFillColor);
        mFillColorSelected = getResources().getColor(R.color.tvg_defFillColorSelected);
        mCornerRadiusX = getResources().getDimension(R.dimen.tvg_defCornerRadius);
        mCornerRadiusY = getResources().getDimension(R.dimen.tvg_defCornerRadius);
        mStrokeWidth = getResources().getDimension(R.dimen.tvg_defStrokeWidth);
        mStrokeColor = getResources().getColor(R.color.tvg_defStrokeColor);
        mStrokeColorSelected = getResources().getColor(R.color.tvg_defStrokeColorSelected);
        mStrokeMarginLeft = getResources().getDimension(R.dimen.tvg_defStrokeMarginLeft);
        mStrokeMarginTop = getResources().getDimension(R.dimen.tvg_defStrokeMarginTop);
        mStrokeMarginRight = getResources().getDimension(R.dimen.tvg_defStrokeMarginRight);
        mStrokeMarginBottom = getResources().getDimension(R.dimen.tvg_defStrokeMarginBottom);
        mStrokeSpacingLeft = getResources().getDimension(R.dimen.tvg_defStrokeSpacingLeft);
        mStrokeSpacingTop = getResources().getDimension(R.dimen.tvg_defStrokeSpacingTop);
        mStrokeSpacingRight = getResources().getDimension(R.dimen.tvg_defStrokeSpacingRight);
        mStrokeSpacingBottom = getResources().getDimension(R.dimen.tvg_defStrokeSpacingBottom);
    }

    addOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState == SCROLL_STATE_IDLE) {
                mEdgeChange = false;
                mHardScrollChange = false;
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mScrollY = mScrollY + dy;

            if (mStrokeCellCurrentBounds == null || mStrokeCell == null)
                return;

            if (useAnimations()) {
                mSelectorAnimationSet.cancel();

                mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx,
                        mStrokeCellCurrentBounds.top - dy);

                performSelectorAnimation();
            } else if (mHardScrollChange || mEdgeChange) {
                mStrokeCellCurrentBounds.offsetTo(mStrokeCellCurrentBounds.left - dx,
                        mStrokeCellCurrentBounds.top - dy);
                setPrevBounds();

                mStrokeCell.setBounds(mStrokeCellPrevBounds);
                invalidate();
            }
        }
    });

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            clearHighlightedView();
            return false;
        }
    });
}

From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java

private 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(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? supportedAbisLollipop()
                            : supportedAbisKitKat()))
            .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(/* w ww  .  j a v a2  s .  com*/
            "Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass()
                    + (activityManager.isLowRamDevice() ? " (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");
}

From source file:com.mylikes.likes.etchasketch.Slate.java

@SuppressLint("NewApi")
private void init() {
    //        setWillNotCacheDrawing(true);
    //        setDrawingCacheEnabled(false);

    mEmpty = true;//from   w ww  .  j  a v a 2  s.  c  om

    // 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(Paint.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(Paint.Style.FILL);
        mDebugPaints[4].setARGB(255, 128, 128, 128);
    }
}

From source file:com.landenlabs.all_devtool.SystemFragment.java

public void updateList() {
    // Time today = new Time(Time.getCurrentTimezone());
    // today.setToNow();
    // today.format(" %H:%M:%S")
    Date dt = new Date();
    m_titleTime.setText(m_timeFormat.format(dt));

    boolean expandAll = m_list.isEmpty();
    m_list.clear();/*from www . j  a  v a  2s  .co m*/

    // Swap colors
    int color = m_rowColor1;
    m_rowColor1 = m_rowColor2;
    m_rowColor2 = color;

    ActivityManager actMgr = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);

    try {
        String androidIDStr = Settings.Secure.getString(getContext().getContentResolver(),
                Settings.Secure.ANDROID_ID);
        addBuild("Android ID", androidIDStr);

        try {
            AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext());
            final String adIdStr = adInfo.getId();
            final boolean isLAT = adInfo.isLimitAdTrackingEnabled();
            addBuild("Ad ID", adIdStr);
        } catch (IOException e) {
            // Unrecoverable error connecting to Google Play services (e.g.,
            // the old version of the service doesn't support getting AdvertisingId).
        } catch (GooglePlayServicesNotAvailableException e) {
            // Google Play services is not available entirely.
        }

        /*
        try {
        InstanceID instanceID = InstanceID.getInstance(getContext());
        if (instanceID != null) {
            // Requires a Google Developer project ID.
            String authorizedEntity = "<need to make this on google developer site>";
            instanceID.getToken(authorizedEntity, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
            addBuild("Instance ID", instanceID.getId());
        }
        } catch (Exception ex) {
        }
        */

        ConfigurationInfo info = actMgr.getDeviceConfigurationInfo();
        addBuild("OpenGL", info.getGlEsVersion());
    } catch (Exception ex) {
        m_log.e(ex.getMessage());
    }

    try {
        long heapSize = Debug.getNativeHeapSize();
        // long maxHeap = Runtime.getRuntime().maxMemory();

        // ConfigurationInfo cfgInfo = actMgr.getDeviceConfigurationInfo();
        int largHeapMb = actMgr.getLargeMemoryClass();
        int heapMb = actMgr.getMemoryClass();

        MemoryInfo memInfo = new MemoryInfo();
        actMgr.getMemoryInfo(memInfo);

        final String sFmtMB = "%.2f MB";
        Map<String, String> listStr = new TreeMap<String, String>();
        listStr.put("Mem Available (now)", String.format(sFmtMB, (double) memInfo.availMem / MB));
        listStr.put("Mem LowWhenOnlyAvail", String.format(sFmtMB, (double) memInfo.threshold / MB));
        if (Build.VERSION.SDK_INT >= 16) {
            listStr.put("Mem Installed", String.format(sFmtMB, (double) memInfo.totalMem / MB));
        }
        listStr.put("Heap (this app)", String.format(sFmtMB, (double) heapSize / MB));
        listStr.put("HeapMax (default)", String.format(sFmtMB, (double) heapMb));
        listStr.put("HeapMax (large)", String.format(sFmtMB, (double) largHeapMb));
        addBuild("Memory...", listStr);
    } catch (Exception ex) {
        m_log.e(ex.getMessage());
    }

    try {
        List<ProcessErrorStateInfo> procErrList = actMgr.getProcessesInErrorState();
        int errCnt = (procErrList == null ? 0 : procErrList.size());
        procErrList = null;

        // List<RunningAppProcessInfo> procList = actMgr.getRunningAppProcesses();
        int procCnt = actMgr.getRunningAppProcesses().size();
        int srvCnt = actMgr.getRunningServices(100).size();

        Map<String, String> listStr = new TreeMap<String, String>();
        listStr.put("#Processes", String.valueOf(procCnt));
        listStr.put("#Proc With Err", String.valueOf(errCnt));
        listStr.put("#Services", String.valueOf(srvCnt));
        // Requires special permission
        //   int taskCnt = actMgr.getRunningTasks(100).size();
        //   listStr.put("#Tasks",  String.valueOf(taskCnt));
        addBuild("Processes...", listStr);
    } catch (Exception ex) {
        m_log.e("System-Processes %s", ex.getMessage());
    }

    try {
        Map<String, String> listStr = new LinkedHashMap<String, String>();
        listStr.put("LargeIconDensity", String.valueOf(actMgr.getLauncherLargeIconDensity()));
        listStr.put("LargeIconSize", String.valueOf(actMgr.getLauncherLargeIconSize()));
        putIf(listStr, "isRunningInTestHarness", "Yes", ActivityManager.isRunningInTestHarness());
        putIf(listStr, "isUserAMonkey", "Yes", ActivityManager.isUserAMonkey());
        addBuild("Misc...", listStr);
    } catch (Exception ex) {
        m_log.e("System-Misc %s", ex.getMessage());
    }

    // --------------- Locale / Timezone -------------
    try {
        Locale ourLocale = Locale.getDefault();
        Date m_date = new Date();
        TimeZone tz = TimeZone.getDefault();

        Map<String, String> localeListStr = new LinkedHashMap<String, String>();

        localeListStr.put("Locale Name", ourLocale.getDisplayName());
        localeListStr.put(" Variant", ourLocale.getVariant());
        localeListStr.put(" Country", ourLocale.getCountry());
        localeListStr.put(" Country ISO", ourLocale.getISO3Country());
        localeListStr.put(" Language", ourLocale.getLanguage());
        localeListStr.put(" Language ISO", ourLocale.getISO3Language());
        localeListStr.put(" Language Dsp", ourLocale.getDisplayLanguage());

        localeListStr.put("TimeZoneID", tz.getID());
        localeListStr.put(" DayLightSavings", tz.useDaylightTime() ? "Yes" : "No");
        localeListStr.put(" In DLS", tz.inDaylightTime(m_date) ? "Yes" : "No");
        localeListStr.put(" Short Name", tz.getDisplayName(false, TimeZone.SHORT, ourLocale));
        localeListStr.put(" Long Name", tz.getDisplayName(false, TimeZone.LONG, ourLocale));

        addBuild("Locale TZ...", localeListStr);
    } catch (Exception ex) {
        m_log.e("Locale/TZ %s", ex.getMessage());
    }

    // --------------- Location Services -------------
    try {
        Map<String, String> listStr = new LinkedHashMap<String, String>();

        final LocationManager locMgr = (LocationManager) getActivity()
                .getSystemService(Context.LOCATION_SERVICE);

        GpsStatus gpsStatus = locMgr.getGpsStatus(null);
        if (gpsStatus != null) {
            listStr.put("Sec ToGetGPS", String.valueOf(gpsStatus.getTimeToFirstFix()));

            Iterable<GpsSatellite> satellites = gpsStatus.getSatellites();
            Iterator<GpsSatellite> sat = satellites.iterator();
            while (sat.hasNext()) {
                GpsSatellite satellite = sat.next();

                putIf(listStr,
                        String.format("Azm:%.0f, Elev:%.0f", satellite.getAzimuth(), satellite.getElevation()),
                        String.format("%.2f Snr", satellite.getSnr()), satellite.usedInFix());
            }
        }

        Location location = null;
        if (ActivityCompat.checkSelfPermission(getContext(),
                Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                || ActivityCompat.checkSelfPermission(getContext(),
                        Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {

            location = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (null == location)
                location = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            if (null == location)
                location = locMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
        }

        if (null != location) {
            listStr.put(location.getProvider() + " lat,lng",
                    String.format("%.3f, %.3f", location.getLatitude(), location.getLongitude()));
        }
        if (listStr.size() != 0) {
            List<String> gpsProviders = locMgr.getAllProviders();
            int idx = 1;
            for (String providerName : gpsProviders) {
                LocationProvider provider = locMgr.getProvider(providerName);
                if (null != provider) {
                    listStr.put(providerName,
                            (locMgr.isProviderEnabled(providerName) ? "On " : "Off ")
                                    + String.format("Accuracy:%d Pwr:%d", provider.getAccuracy(),
                                            provider.getPowerRequirement()));
                }
            }
            addBuild("GPS...", listStr);
        } else
            addBuild("GPS", "Off");
    } catch (Exception ex) {
        m_log.e(ex.getMessage());
    }

    // --------------- Application Info -------------
    ApplicationInfo appInfo = getActivity().getApplicationInfo();
    if (null != appInfo) {
        Map<String, String> appList = new LinkedHashMap<String, String>();
        try {
            appList.put("ProcName", appInfo.processName);
            appList.put("PkgName", appInfo.packageName);
            appList.put("DataDir", appInfo.dataDir);
            appList.put("SrcDir", appInfo.sourceDir);
            //    appList.put("PkgResDir", getActivity().getPackageResourcePath());
            //     appList.put("PkgCodeDir", getActivity().getPackageCodePath());
            String[] dbList = getActivity().databaseList();
            if (dbList != null && dbList.length != 0)
                appList.put("DataBase", dbList[0]);
            // getActivity().getComponentName().

        } catch (Exception ex) {
        }
        addBuild("AppInfo...", appList);
    }

    // --------------- Account Services -------------
    final AccountManager accMgr = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE);
    if (null != accMgr) {
        Map<String, String> strList = new LinkedHashMap<String, String>();
        try {
            for (Account account : accMgr.getAccounts()) {
                strList.put(account.name, account.type);
            }
        } catch (Exception ex) {
            m_log.e(ex.getMessage());
        }
        addBuild("Accounts...", strList);
    }

    // --------------- Package Features -------------
    PackageManager pm = getActivity().getPackageManager();
    FeatureInfo[] features = pm.getSystemAvailableFeatures();
    if (features != null) {
        Map<String, String> strList = new LinkedHashMap<String, String>();
        for (FeatureInfo featureInfo : features) {
            strList.put(featureInfo.name, "");
        }
        addBuild("Features...", strList);
    }

    // --------------- Sensor Services -------------
    final SensorManager senMgr = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    if (null != senMgr) {
        Map<String, String> strList = new LinkedHashMap<String, String>();
        // Sensor accelerometer = senMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        // senMgr.registerListener(foo, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
        List<Sensor> listSensor = senMgr.getSensorList(Sensor.TYPE_ALL);
        try {
            for (Sensor sensor : listSensor) {
                strList.put(sensor.getName(), sensor.getVendor());
            }
        } catch (Exception ex) {
            m_log.e(ex.getMessage());
        }
        addBuild("Sensors...", strList);
    }

    try {
        if (Build.VERSION.SDK_INT >= 17) {
            final UserManager userMgr = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
            if (null != userMgr) {
                try {
                    addBuild("UserName", userMgr.getUserName());
                } catch (Exception ex) {
                    m_log.e(ex.getMessage());
                }
            }
        }
    } catch (Exception ex) {
    }

    try {
        Map<String, String> strList = new LinkedHashMap<String, String>();
        int screenTimeout = Settings.System.getInt(getActivity().getContentResolver(),
                Settings.System.SCREEN_OFF_TIMEOUT);
        strList.put("ScreenTimeOut", String.valueOf(screenTimeout / 1000));
        int rotate = Settings.System.getInt(getActivity().getContentResolver(),
                Settings.System.ACCELEROMETER_ROTATION);
        strList.put("RotateEnabled", String.valueOf(rotate));
        if (Build.VERSION.SDK_INT >= 17) {
            // Global added in API 17
            int adb = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED);
            strList.put("AdbEnabled", String.valueOf(adb));
        }
        addBuild("Settings...", strList);
    } catch (Exception ex) {
    }

    if (expandAll) {
        // updateList();
        int count = m_list.size();
        for (int position = 0; position < count; position++)
            m_listView.expandGroup(position);
    }

    m_adapter.notifyDataSetChanged();
}

From source file:com.skytree.epubtest.BookViewActivity.java

public void reportMemory() {
    Runtime rt = Runtime.getRuntime();
    long maxMemory = rt.maxMemory();

    //      Log.v("EPub", "maxMemory:" + Long.toString(maxMemory));

    ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    int memoryClass = am.getMemoryClass();
    //      Log.v("EPub", "memoryClass:" + Integer.toString(memoryClass));   

    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    MemoryInfo memoryInfo = new MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    //      Log.i("EPub", "AvailMem" + memoryInfo.availMem);

    long memoryAvail = memoryInfo.availMem;
    long memoryAlloc = maxMemory - memoryAvail;

    String message = String.format("Max :%d Avail:%d", maxMemory, memoryAvail);
    showToast(message);/*from   w  w  w . j a  v a2s  .  com*/
}