Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get screen pixels in Android

Shulou Source: shulou.com Published: 2022-05-31 22:01:25 09月15日 Update

This article focuses on "how to get screen pixels in Android". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor learn "how to get screen pixels in Android".

The code is as follows:

Private void alertScreenDialog () {DisplayMetrics dm = new DisplayMetrics (); getWindowManager (). GetDefaultDisplay (). GetMetrics (dm); String optStr = "Mobile screen resolution is: + dm.widthPixels+" x "+ dm.heightPixels; Builder builder = new Builder (this); builder.setMessage (optStr); builder.setIcon (R.drawable.firefox); builder.setTitle (" get screen pixels ") / / Click OK button builder.setPositiveButton ("OK", new DialogInterface.OnClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {Toast.makeText (GetScreenActivity.this, "get Pixel", Toast.LENGTH_LONG) .show ();}}) Builder.setNegativeButton ("return", new DialogInterface.OnClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {Toast.makeText (GetScreenActivity.this, "return", Toast.LENGTH_LONG) .show ();}}); builder.create () .show () What is Android? Android is a free and open source operating system based on the Linux kernel, mainly used in mobile devices, such as smartphones and tablets, led and developed by Google and the Open Mobile Alliance.

At this point, I believe you have a deeper understanding of "how to get screen pixels in Android". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Pixels screen mobile phone content learning open practical deeper free operating system code company interest kernel resolution practicality practical tablet tablet button Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Technology Linux Redmi Huawei