Android examples for User Interface:Toast
show device Density in Toast
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.widget.Toast; public class Main { public static void deviceDensity(Context context) { int density = context.getResources().getDisplayMetrics().densityDpi; switch (density) { case DisplayMetrics.DENSITY_LOW: Toast.makeText(context, "LDPI", Toast.LENGTH_SHORT).show(); break; case DisplayMetrics.DENSITY_MEDIUM: Toast.makeText(context, "MDPI", Toast.LENGTH_SHORT).show(); break; case DisplayMetrics.DENSITY_HIGH: Toast.makeText(context, "HDPI", Toast.LENGTH_SHORT).show(); break; case DisplayMetrics.DENSITY_XHIGH: Toast.makeText(context, "XHDPI", Toast.LENGTH_SHORT).show(); break; }// w w w . jav a 2 s . c om } }