PHP
·
发表于 5年以前
·
阅读量:8073
public static String getDisplay(Context context )
{
DisplayMetrics metrics = new DisplayMetrics();
WindowManager manager = (WindowManager)context.getSystemService( Context.WINDOW_SERVICE );
Display display = manager.getDefaultDisplay();
display.getMetrics( metrics );
DisplayMetrics dm = new DisplayMetrics();
@SuppressWarnings( "rawtypes" )
Class c;
try
{
c = Class.forName( "android.view.Display" );
@SuppressWarnings( "unchecked" )
Method method = c.getMethod( "getRealMetrics" , DisplayMetrics.class );
method.invoke( display , dm );
return dm.widthPixels + "*" + dm.heightPixels;
}
catch( Exception e )
{
return metrics.widthPixels + "*" + metrics.heightPixels;
}
}