Example usage for android.util DisplayMetrics DENSITY_MEDIUM

List of usage examples for android.util DisplayMetrics DENSITY_MEDIUM

Introduction

In this page you can find the example usage for android.util DisplayMetrics DENSITY_MEDIUM.

Prototype

int DENSITY_MEDIUM

To view the source code for android.util DisplayMetrics DENSITY_MEDIUM.

Click Source Link

Document

Standard quantized DPI for medium-density screens.

Usage

From source file:org.altusmetrum.AltosDroid.AltosDroid.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)//from w w w . j  av a  2  s  .c  o m
        Log.e(TAG, "+++ ON CREATE +++");

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    // Initialise preferences
    prefs = new AltosDroidPreferences(this);
    AltosPreferences.init(prefs);

    // Set up the window layout
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.altosdroid);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    // Create the Tabs and ViewPager
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    mViewPager = (AltosViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(4);

    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    mTabsAdapter.addTab(mTabHost.newTabSpec("pad").setIndicator("Pad"), TabPad.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("ascent").setIndicator("Ascent"), TabAscent.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator("Descent"), TabDescent.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator("Landed"), TabLanded.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator("Map"), TabMap.class, null);

    // Scale the size of the Tab bar for different screen densities
    // This probably won't be needed when we start supporting ICS+ tabs.
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int density = metrics.densityDpi;

    if (density == DisplayMetrics.DENSITY_XHIGH)
        tabHeight = 65;
    else if (density == DisplayMetrics.DENSITY_HIGH)
        tabHeight = 45;
    else if (density == DisplayMetrics.DENSITY_MEDIUM)
        tabHeight = 35;
    else if (density == DisplayMetrics.DENSITY_LOW)
        tabHeight = 25;
    else
        tabHeight = 65;

    for (int i = 0; i < 5; i++)
        mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = tabHeight;

    // Set up the custom title
    mTitle = (TextView) findViewById(R.id.title_left_text);
    mTitle.setText(R.string.app_name);
    mTitle = (TextView) findViewById(R.id.title_right_text);

    // Display the Version
    mVersion = (TextView) findViewById(R.id.version);
    mVersion.setText("Version: " + BuildInfo.version + "  Built: " + BuildInfo.builddate + " "
            + BuildInfo.buildtime + " " + BuildInfo.buildtz + "  (" + BuildInfo.branch + "-"
            + BuildInfo.commitnum + "-" + BuildInfo.commithash + ")");

    mCallsignView = (TextView) findViewById(R.id.callsign_value);
    mRSSIView = (TextView) findViewById(R.id.rssi_value);
    mSerialView = (TextView) findViewById(R.id.serial_value);
    mFlightView = (TextView) findViewById(R.id.flight_value);
    mStateView = (TextView) findViewById(R.id.state_value);
    mAgeView = (TextView) findViewById(R.id.age_value);

    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            onTimerTick();
        }
    }, 1000L, 100L);

    mAltosVoice = new AltosVoice(this);
}

From source file:uni.oulu.mentor.TeacherVisionActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //DO NOT USE THIS SERVICE YET, DOES NOT WORK
    //Intent intent = new Intent(this, TeacherVisionService.class);
    //startService(intent);
    /*Idea from http://stackoverflow.com/questions/2902640/android-get-the-screen-resolution-pixels-as-integer-values */
    @SuppressWarnings("deprecation")
    int screenWidthPix = getWindowManager().getDefaultDisplay().getWidth();
    @SuppressWarnings("deprecation")
    int screenHeightPix = getWindowManager().getDefaultDisplay().getHeight();
    /*Idea from http://stackoverflow.com/questions/5015094/determine-device-screen-category-small-normal-large-xlarge-using-code*/
    if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE)
        screenType = 3;//from   w ww. ja  v a  2s .  c  o  m
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE)
        screenType = 4;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL)
        screenType = 1;
    else if ((getResources().getConfiguration().screenLayout
            & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL)
        screenType = 2;
    //screen density is investigated here
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int density = metrics.densityDpi;
    if (density == DisplayMetrics.DENSITY_HIGH) {
        //400 dpi is 600px
        if (screenType == 1)
            translationX = 240; //240 / 1.5 = 160
        else if (screenType == 2)
            translationX = 315; //315 / 1.5 = 210 in dpi, screen 800 pix wide screen, needs about 1024/400 = 800/x => 312,5, 2.56
        else if (screenType == 3)
            translationX = 540; //540 / 1.5 = 360 in dpi
        else if (screenType == 4)
            translationX = 600; //600 / 1.5 = 400 in dpi   
    } else if (density == DisplayMetrics.DENSITY_MEDIUM) {
        //400 dpi is 400px
        if (screenType == 1)
            translationX = 160; //160 / 1 = 160 in dpi
        else if (screenType == 2)
            translationX = 210; //210 / 1 = 210 in dpi
        else if (screenType == 3)
            translationX = 360; //360 / 1 = 360 in dpi
        else if (screenType == 4)
            translationX = 400; //400 / 1 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_LOW) {
        //400 dpi is 300px
        if (screenType == 1)
            translationX = 120; //120 / 0.75 = 160 in dpi
        else if (screenType == 2)
            translationX = 158; //158 / 0.75 = 210 in dpi
        else if (screenType == 3)
            translationX = 270; //270 / 0.75 = 360 in dpi
        else if (screenType == 4)
            translationX = 300; //300 / 0.75 = 400 in dpi
    } else if (density == DisplayMetrics.DENSITY_XHIGH || density == DisplayMetrics.DENSITY_XXHIGH) {
        //400 dpi is 800px
        if (screenType == 1)
            translationX = 320; //320 / 2 = 160 in dpi
        else if (screenType == 2)
            translationX = 420; // 420 / 2 = 210 in dpi
        else if (screenType == 3)
            translationX = 720; // 720 / 2 = 360 in dpi
        else if (screenType == 4)
            translationX = 800; // 800 / 2 = 400 in dpi         
    } else {
        //not supported
    }
    int offsetX = ((int) screenWidthPix / 20);
    int offsetY = ((int) screenHeightPix / 10);
    maxPosOpenX = screenWidthPix;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel open touch
    minPosOpenX = screenWidthPix - offsetX;
    //boundary for maximum amount of width on x-axis, where the touch is seen as panel close touch
    maxPosCloseX = screenWidthPix - translationX + offsetX;
    //boundary for minimum amount of width on x-axis, where the touch is seen as panel close touch
    minPosCloseX = screenWidthPix - translationX - offsetX;
    //boundary for maximum amount of height on y-axis, where the touch is seen as panel open or close touch
    maxPosY = (screenHeightPix / 2) + offsetY;
    //boundary for minimum amount of height on y-axis, where the touch is seen as panel open or close touch
    minPosY = (screenHeightPix / 2) - offsetY;
    //instantiation of lists
    onlineStudentsList = new ArrayList<Student>();
    feedbacksList = new ArrayList<Feedback>();
    questionsList = new ArrayList<Question>();
    answersList = new ArrayList<Answer>();
    ownQuestionsList = new ArrayList<Question>();
    //data stored for this user is fetched here, from the previous activity, and stored into the teacher instance
    Intent intent2 = getIntent();
    teacher = (Teacher) intent2.getParcelableExtra("teacherObj");
    ipStr = getResources().getString(R.string.IP);
    usersUrl = "http://" + ipStr + "/mentor/users";
    coursesUrl = "http://" + ipStr + "/mentor/courses";
    //default preferences are fetched, and listener is set to listen for preference changes
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sp.registerOnSharedPreferenceChangeListener(this);
    //SharedPreferences.Editor editor = sp.edit();
    //editor.putString("flaretimePref", "5");
    //editor.clear();
    //editor.commit();
    // In case of notifications are added later
    /*String ns = Context.NOTIFICATION_SERVICE;
    mNotificationManager = (NotificationManager) getSystemService(ns);
    icon = R.drawable.mlogo2;*/
    //AndAR preview
    renderer = new CustomRenderer();//optional, may be set to null
    super.setNonARRenderer(renderer);//or might be omitted
    try {
        //register an object for each marker type
        artoolkit = super.getArtoolkit();
        oneObject = new CustomObject("onePatt", "onePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter, customColor
        twoObject = new CustomObject("twoPatt", "twoPatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        threeObject = new CustomObject("threePatt", "threePatt.patt", 80.0, new double[] { 0, 0 }); //name, pattern, markerWidth, markerCenter
        artoolkit.registerARObject(oneObject);
        artoolkit.registerARObject(twoObject);
        artoolkit.registerARObject(threeObject);
    } catch (AndARException ex) {
        Log.e("AndARException ", ex.getMessage());
    }
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View vv = inflater.inflate(R.layout.activity_teacher_vision, null);
    //screen width and height in pixels
    screenWidth = (float) this.getApplicationContext().getResources().getDisplayMetrics().widthPixels;
    screenHeight = (float) this.getApplicationContext().getResources().getDisplayMetrics().heightPixels;
    inflater.inflate(R.layout.fragment_teacher_vision, null);
    //UI elements are added on top of AndAR by calling this addContentView-method instead of setContentView
    super.addContentView(vv, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //create a layout for settings button. add it over video frames
    LinearLayout lil = new LinearLayout(this);
    Button settingsButton = new Button(this);
    settingsButton.setText("Settings");
    settingsButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    settingsButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragment())
                    .addToBackStack("settings").commit();
        }
    });
    lil.addView(settingsButton);
    super.addContentView(lil, (new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)));
    //starts the AndAR
    startPreview();
    //mDetector is instantiated here for detecting gestures
    mDetector = new GestureDetectorCompat(this, new SwipeGestureListener());
    //view pager instantiation, also mAdapter instantiated and set as adapter for view pager
    mPager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new TabAdapter(getFragmentManager(), mPager);
    mPager.setAdapter(mAdapter);
    //begin to poll online users
    pollUsersCancelled = false;
    pollUsersTask = new PollUsersTask(this);
    pollUsersTask.execute();
    //begin to poll feedbacks
    pollFeedbacksCancelled = false;
    pollFeedbacksTask = new PollFeedbacksTask(this);
    pollFeedbacksTask.execute();
    //begin to poll questions
    pollQuestionsCancelled = false;
    pollQuestionsTask = new PollQuestionsTask(this);
    pollQuestionsTask.execute();
    //begin to poll answers
    pollAnswersCancelled = false;
    pollAnswersTask = new PollAnswersTask(this);
    pollAnswersTask.execute();
    //initialize tab buttons
    button = (Button) findViewById(R.id.goto_first);
    //first one is not enabled at the beginning, because the user is in first tab at first 
    button.setEnabled(false);
    button2 = (Button) findViewById(R.id.goto_second);
    button3 = (Button) findViewById(R.id.goto_last);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(0);
            button.setEnabled(false);
            button2.setEnabled(true);
            button3.setEnabled(true);
        }
    });
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(1);
            button.setEnabled(true);
            button2.setEnabled(false);
            button3.setEnabled(true);
        }
    });
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mPager.setCurrentItem(2);
            button.setEnabled(true);
            button2.setEnabled(true);
            button3.setEnabled(false);
        }
    });
}

From source file:com.linkbubble.util.Util.java

private static int getAlertIconDensityDpi(Context context) {
    if (sDensityDpi == null) {
        sDensityDpi = context.getResources().getDisplayMetrics().densityDpi;
    }/*from w w w.ja v a2s  .com*/

    switch (sDensityDpi) {
    case DisplayMetrics.DENSITY_LOW:
    case DisplayMetrics.DENSITY_MEDIUM:
        return DisplayMetrics.DENSITY_LOW;
    case DisplayMetrics.DENSITY_TV:
    case DisplayMetrics.DENSITY_HIGH:
        return DisplayMetrics.DENSITY_MEDIUM;
    case DisplayMetrics.DENSITY_XHIGH:
        return DisplayMetrics.DENSITY_HIGH;
    case DisplayMetrics.DENSITY_XXHIGH:
    case DisplayMetrics.DENSITY_XXXHIGH:
        return DisplayMetrics.DENSITY_XHIGH;
    }

    return sDensityDpi;
}

From source file:org.mozilla.gecko.GeckoAppShell.java

static private Bitmap getLauncherIcon(Bitmap aSource) {
    final int kOffset = 6;
    final int kRadius = 5;
    int kIconSize;
    int kOverlaySize;
    switch (getDpi()) {
    case DisplayMetrics.DENSITY_MEDIUM:
        kIconSize = 48;/*from  ww w . j a  v a 2  s .c o m*/
        kOverlaySize = 32;
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        kIconSize = 96;
        kOverlaySize = 48;
        break;
    case DisplayMetrics.DENSITY_HIGH:
    default:
        kIconSize = 72;
        kOverlaySize = 32;
    }

    Bitmap bitmap = Bitmap.createBitmap(kIconSize, kIconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // draw a base color
    Paint paint = new Paint();

    if (aSource == null) {
        float[] hsv = new float[3];
        hsv[0] = 32.0f;
        hsv[1] = 1.0f;
        hsv[2] = 1.0f;
        paint.setColor(Color.HSVToColor(hsv));
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
    } else {
        int color = BitmapUtils.getDominantColor(aSource);
        paint.setColor(color);
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
        paint.setColor(Color.argb(100, 255, 255, 255));
        canvas.drawRoundRect(new RectF(kOffset, kOffset, kIconSize - kOffset, kIconSize - kOffset), kRadius,
                kRadius, paint);
    }

    // draw the overlay
    Bitmap overlay = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_bg);
    canvas.drawBitmap(overlay, null, new Rect(0, 0, kIconSize, kIconSize), null);

    // draw the bitmap
    if (aSource == null)
        aSource = BitmapFactory.decodeResource(GeckoApp.mAppContext.getResources(), R.drawable.home_star);

    if (aSource.getWidth() < kOverlaySize || aSource.getHeight() < kOverlaySize) {
        canvas.drawBitmap(aSource, null,
                new Rect(kIconSize / 2 - kOverlaySize / 2, kIconSize / 2 - kOverlaySize / 2,
                        kIconSize / 2 + kOverlaySize / 2, kIconSize / 2 + kOverlaySize / 2),
                null);
    } else {
        canvas.drawBitmap(aSource, null,
                new Rect(kIconSize / 2 - aSource.getWidth() / 2, kIconSize / 2 - aSource.getHeight() / 2,
                        kIconSize / 2 + aSource.getWidth() / 2, kIconSize / 2 + aSource.getHeight() / 2),
                null);
    }

    return bitmap;
}

From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java

/**
* This is a rather unintuitive helper method to load images. The reason why this method exists
* is because due to some service limitations, one may not be able to add images to native
* resource bundle. So this method offers a way to load image from www contents instead.
* However loading from native resource bundle is already preferred over loading from www. So
* if name is given, then it simply loads from resource bundle and the other two parameters are
* ignored. If name is not given, then altPath is assumed to be a file path _under_ www and
* altDensity is the desired density of the given image file, because without native resource
* bundle, we can't tell what density the image is supposed to be so it needs to be given
* explicitly./*from www.  ja v  a2  s . c  o  m*/
*/
private Drawable getImage(String name, String altPath, double altDensity) throws IOException {
    Drawable result = null;
    Resources activityRes = cordova.getActivity().getResources();

    if (name != null) {
        int id = activityRes.getIdentifier(name, "drawable", cordova.getActivity().getPackageName());
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            result = activityRes.getDrawable(id);
        } else {
            result = activityRes.getDrawable(id, cordova.getActivity().getTheme());
        }
    } else if (altPath != null) {
        File file = new File("www", altPath);
        InputStream is = null;
        try {
            is = cordova.getActivity().getAssets().open(file.getPath());
            Bitmap bitmap = BitmapFactory.decodeStream(is);
            bitmap.setDensity((int) (DisplayMetrics.DENSITY_MEDIUM * altDensity));
            result = new BitmapDrawable(activityRes, bitmap);
        } finally {
            // Make sure we close this input stream to prevent resource leak.
            try {
                is.close();
            } catch (Exception e) {
            }
        }
    }
    return result;
}

From source file:com.mobicage.rogerthat.MainService.java

public int getScreenScale() {
    // Based on UIScreen.scale on iOS
    if (mScreenScale == null) {
        switch (getResources().getDisplayMetrics().densityDpi) {
        case DisplayMetrics.DENSITY_LOW:
            mScreenScale = 1;//w  ww .  ja v  a 2 s . co m
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            mScreenScale = 2;
            break;
        case DisplayMetrics.DENSITY_HIGH:
            mScreenScale = 3;
            break;
        default:
            mScreenScale = 2;
            break;
        }
    }

    return mScreenScale;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public int getDeviceDensity() {
    DisplayMetrics metrics = new DisplayMetrics();
    if (getActivity() != null) {
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    } else {//from  w w  w  . ja v a 2s. c  o m
        metrics = getContext().getResources().getDisplayMetrics();
    }

    if (metrics.densityDpi < DisplayMetrics.DENSITY_MEDIUM) {
        return Display.DENSITY_LOW;
    }

    if (metrics.densityDpi < 213) {
        return Display.DENSITY_MEDIUM;
    }

    // 213 == TV
    if (metrics.densityDpi >= 213 && metrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) {
        return Display.DENSITY_HIGH;
    }

    if (metrics.densityDpi > DisplayMetrics.DENSITY_HIGH && metrics.densityDpi < 400) {
        return Display.DENSITY_VERY_HIGH;
    }

    if (metrics.densityDpi >= 400 && metrics.densityDpi < 560) {
        return Display.DENSITY_HD;
    }

    if (metrics.densityDpi >= 560 && metrics.densityDpi <= 640) {
        return Display.DENSITY_2HD;
    }
    if (metrics.densityDpi > 640) {
        return Display.DENSITY_4K;
    }

    return Display.DENSITY_MEDIUM;
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWindow.java

public void openAdMsg(String[] parm) {
    EBrowserWindow curWind = mBrwView.getBrowserWindow();
    if (null == curWind) {
        return;/*from   w w w  .java2 s  .  c o m*/
    }
    WWidgetData wd = mBrwView.getCurrentWidget();
    boolean b1 = mBrwView.checkType(EBrwViewEntry.VIEW_TYPE_MAIN);
    boolean b2 = 0 == wd.m_widgetAdStatus;
    boolean b3 = parm.length < 4;
    if (!b1 || b2 || b3) {
        // 0 means do not show ad
        return;
    }
    String inType = parm[0];
    String inDTime = parm[1];
    String inInterval = parm[2];
    String inFlag = parm[3];
    int type = 0, flag = 0, dtime = 0, interval = 0, w = RelativeLayout.LayoutParams.FILL_PARENT, h = 50;
    MessageDigest md = null;
    int density = ESystemInfo.getIntence().mDensityDpi;
    switch (density) {
    case DisplayMetrics.DENSITY_LOW:
        h = 40;
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        h = 50;
        break;
    case DisplayMetrics.DENSITY_HIGH:
        h = 60;
        break;
    case 320: // DisplayMetrics.DENSITY_XHIGH from 2.3.3
        h = 70;
        break;
    }
    try {
        if (null != inType && inType.length() != 0) {
            type = Integer.parseInt(inType);
        }

        if (null != inDTime && inDTime.length() != 0) {
            dtime = Integer.parseInt(inDTime);
        }

        if (null != inInterval && inInterval.length() != 0) {
            interval = Integer.parseInt(inInterval);
        }

        if (null != inFlag && inFlag.length() != 0) {
            flag = Integer.parseInt(inFlag);
        }
        md = MessageDigest.getInstance("MD5");
    } catch (Exception e) {
        errorCallback(0, EUExCallback.F_E_UEXWINDOW_EVAL, "Illegal parameter");
        return;
    }
    StringBuffer sb = new StringBuffer(m_AdUrl);
    sb.append("?appid=");
    sb.append(wd.m_appId);
    sb.append("&pt=1");
    sb.append("&dw=");
    sb.append(ESystemInfo.getIntence().mWidthPixels);
    sb.append("&dh=");
    sb.append(ESystemInfo.getIntence().mHeightPixels);
    sb.append("&md5=");
    if (null == md) {
        return;
    }
    String jid = wd.m_appId + "BD7463CD-D608-BEB4-C633-EF3574213060";
    md.reset();
    md.update(jid.getBytes());
    byte[] md5Bytes = md.digest();
    StringBuffer hexValue = new StringBuffer();
    for (int i = 0; i < md5Bytes.length; i++) {
        int val = ((int) md5Bytes[i]) & 0xff;
        if (val < 16)
            hexValue.append("0");
        hexValue.append(Integer.toHexString(val));
    }
    sb.append(hexValue);
    sb.append("&type=");
    if (type == 1) {
        sb.append(1);
        h = w;
    } else {
        sb.append(0);
    }
    String url = sb.toString();
    curWind.openAd(type, url, dtime * 1000, h, w, interval * 1000, flag);
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Returns the device resolution type./* w  w w. ja  v  a  2  s .c om*/
 * 
 * @param context
 * @return   {@link es.javocsoft.android.lib.toolbox.ToolBox.DEVICE_RESOLUTION_TYPE}
 */
public static DEVICE_RESOLUTION_TYPE device_getResolutionType(Context context) {
    DEVICE_RESOLUTION_TYPE res = null;

    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);

    switch (metrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
        res = DEVICE_RESOLUTION_TYPE.ldpi;
        break;
    case DisplayMetrics.DENSITY_MEDIUM:
        res = DEVICE_RESOLUTION_TYPE.mdpi;
        break;
    case DisplayMetrics.DENSITY_HIGH:
        res = DEVICE_RESOLUTION_TYPE.hdpi;
        break;
    case DisplayMetrics.DENSITY_XHIGH:
        res = DEVICE_RESOLUTION_TYPE.xhdpi;
        break;
    case DisplayMetrics.DENSITY_XXHIGH:
        res = DEVICE_RESOLUTION_TYPE.xxhdpi;
        break;
    }

    return res;
}