DEV Community

Kai
Kai

Posted on

 

Get Android's screen width and height

Inside your Activity:

override fun onStart() {
    val size = Point()
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
        requireContext().display!!.getRealSize(size)
    } else {
        val windowManager = requireContext().getSystemService(Context.WINDOW_SERVICE) as WindowManager
        windowManager.defaultDisplay.getRealSize(size)
    }
    size.x // Width
    size.y // Height
}
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.