# How to retrieve the screen size of the device ?

**URL:** <https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334>\
**Category:** How-to Discussions\
**Created:** [April 19, 2016, 10:01am UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334 "2016-04-19T10:01:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jithesh\_Krishnan1](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@Jithesh\_Krishnan1](https://forums.fusetools.com/u/Jithesh_Krishnan1)\
**Post date:** [April 19, 2016, 10:01am UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/1 "2016-04-19T10:01:09Z")

</div>

Hi,

How to retrieve the screen size of the device as soon as the application is loaded?

Thanks and regards, Jithesh

---

<div class="post-metadata">

**Author:** ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)\
**Post date:** [April 28, 2016, 2:28pm UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/2 "2016-04-28T14:28:09Z")

</div>

Retrieve it from JavaScript or Uno code?

In Uno you do:

```auto
int2 screenSize = Uno.Application.Current.Window.ClientSize;

```

We do not provide any JS APIs for this yet, but you can easily implement a [`NativeModule`](https://www.fusetools.com/learn/fusejs#creating-native-javascript-modules-in-uno) for this

For example:

```auto
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;

public class AppModule : NativeModule
{
    public AppModule()
    {
        AddMember(new NativeFunction("GetClientSize", (NativeCallback)GetClientSize));
    }

    static object GetClientSize(Context c, object[] args)
    {
        var size = Uno.Application.Current.Window.ClientSize;
        return c.NewArray(size.X, size.Y);
    }
}

<AppModule ux:Global="AppModule" />
<JavaScript>
    var AppModule = require("AppModule");
    var w = AppModule.GetClientSize()[0];
    var h = AppModule.GetClientSize()[1];
    console.log("width: " + w + ", height: " + h);
</JavaScript>

```

---

<div class="post-metadata">

**Author:** ![dev](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@dev](https://forums.fusetools.com/u/dev)\
**Post date:** [February 22, 2017, 1:40am UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/3 "2017-02-22T01:40:08Z")

</div>

Uno.Exception: Window ClientSize not available on mobile

‘Uno.Application.Current.Window.ClientSize’ is works on windows preview. but I have runtime fatal error on android.

So, I tried call widthPixels and heightPixels from getRootActivity().getResources().getSystem().getDisplayMetrics()

Android native code can get the resolution of the screen, but fuse is not compatible because it uses point coordinates.

How can I get through this problem?

---

<div class="post-metadata">

**Author:** ![Jae\_Woong\_Kang](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@Jae\_Woong\_Kang](https://forums.fusetools.com/u/Jae_Woong_Kang)\
**Post date:** [March 5, 2017, 4:28am UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/4 "2017-03-05T04:28:02Z")

</div>

Same Problem.  
Is there any news?

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [March 5, 2017, 9:52am UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/5 "2017-03-05T09:52:53Z")

</div>

In UX/JS you can use the `Placed` event to retrieve the size of any element:

```
 <Panel Placed="{placed}">

```

And in JS:

```
  function placed(args) {

```

Where you have `args.width` and `args.height`.

[https://www.fusetools.com/docs/fuse/elements/element/placed](https://www.fusetools.com/docs/fuse/elements/element/placed)

However, this should almost never be needed. I’m interested to know what your use cases are, there are probably a better way of doing it.

---

<div class="post-metadata">

**Author:** ![iUseFuse](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/iusefuse/32/747_2.png) [@iUseFuse](https://forums.fusetools.com/u/iUseFuse)\
**Post date:** [July 30, 2018, 7:00pm UTC](https://forums.fusetools.com/t/how-to-retrieve-the-screen-size-of-the-device/5334/6 "2018-07-30T19:00:54Z")

</div>

> [@Anders\_Lassen](#):
>
> However, this should almost never be needed. I’m interested to know what your use cases are, there are probably a better way of doing it.

Well one case for example is that you want to call an api that returns images and you want to submit the screen resolution of the phone, so the api can return smaller images for smaller phones, which saves traffic.  
That’s at least what i’m working on and also the reason why i came across this thread.
