SoFunction
Updated on 2025-03-04

Android to obtain screen pixel ideas and code


<SPAN style="FONT-SIZE: 18px">private void alertScreenDialog() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String optStr = "The screen resolution of the mobile phone is: "++" x "+;
Builder builder = new Builder(this);
(optStr);
();
("Get screen pixels");
//Click the OK button
("OK", new (){
@Override
public void onClick(DialogInterface dialog, int which) {
(, "Get pixels", Toast.LENGTH_LONG).show();
}
});
("Return", new () {
@Override
public void onClick(DialogInterface dialog, int which) {
(, "Return", Toast.LENGTH_LONG).show();
}
});
().show();
}</SPAN>