Code example for SparseArray

0
import android.view.Surface; 
import android.view.WindowManager; 
 
final class DisplayManagerCollector { 
 
    final static SparseArray<String> mFlagsNames = new SparseArray<String>();
    final static SparseArray<String> mDensities = new SparseArray<String>();
 
    public static String collectDisplays(Context ctx) {
        Display[] displays = null;
        final StringBuilder result = new StringBuilder();
 
        if (Compatibility.getAPILevel() < 17) { 
            // Before Android 4.2, there was a single display available from the 
            // window manager 
            final WindowManager windowManager = (WindowManager) ctx
                    .getSystemService(android.content.Context.WINDOW_SERVICE);
            displays = new Display[1];
            displays[0] = windowManager.getDefaultDisplay();
        } else { 
            // Since Android 4.2, we can fetch multiple displays with the