Screen height and width doesn't match phone resolution using Responsive size

I created an app to test chart plotting using MIP app inventor. My problem is that I want to use the full resolution of the new phones like the One Plus 7 Pro (1440 x 3120 pixels), but whatever I do, I end up limited by what the Screen1 width and height becomes after the apk is running in my phone. I haven't tried other phones, only a One Plus 7 Pro. In the apk I get a maximum of 411 x 835 pixels. Nevertheless, if I use taifunimage extension and save a screenshot and then assess the width and height of the saved image, I get the full resolution of 1440 x 3120. But I can't use it for charting.
I have searched this all over and can't find any answers, can somebody help? Thanks!
I am attaching one of the many tests I wrote, in this one I discovered that I have to wait at least for the second loop of the clock even when the delay is programmed to only one milisecond before I get the correct value in VerticalArrangement1.Height

In this second one I tested wether I could use a fraction for a circle radius and couldn't. I also tested drawing lines over the screen and random numbers to understand how the functions actually work before coding the chart.

And this is the test code for measuring the actual width and height using screenshot

On Home Screen set Sizing as Responsive and not Fixed

Hello Julio

The problem is that you are trying to verify the size of the Screen before it has finished initialising. If you move all the blocks except Clock Timer Enable to the Clock Timer Block, you should see the results required. Timer Interval: 500 millis. Timer Always Fires: false.

It is set the responsive

I will try this later today and look at my test examples taking this into account.

OK, I tested what you said and here is the new test code:

The output is:
Screen1 Height = 835
Screen1 Width = 411
HorizontalArrangement1 Height = 208.75
HorizontalArrangement1 Width = 411
It is interesting to note that had I left the code as it was using the blocks VerticalArrangement1.Height and VerticalArrangement1.Width instead of using the global variables Global scrH y scrW, the Output would have been different, it is like it also takes time for the Set VerticalArrangement1.Height to be reflected into the block VerticalArrangement.Height and the same for width.

I increased the dealy to 1500 or 1.5 seconds to no avail. Still not getting the 1440 x 3120...

The screen output was a png file of 1440 x 3120 pixels:

If I leave everything identical but change the Screen1 Size to Fixed, this is what I get:
Screen1 Height = 649
Screen1 Width = 319
HorizontalArrangement1 Height = 162.25
HorizontalArrangement1 Width = 319
And here is the Screen shot (1440 x 3120 pixels):

Screen height and width are not in the actual number of pixels but in dp.

The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). So for high resolution phones with 516 px/inch, dp = 1440/(516/160) thus 446.51 for the Width and 967 for the Height. This is a factor of 3.225, meaning that if I can only use dp units as integers, then I'd be loosing all the advantages of a high resolution screen. Is there any way to retain them for charting? or
I am dead, am I? My problem is that when I use Canvas functions like drawcircle I want to leverage high resolution screens rather than use fewer dots for charting, like I would if I only use dp units. Thanks

Hi Julio

You have the Clock timer enabled before setting the interval!

My P30 Pro, Android 10:
resolution 1080 x 2340
result 360 x 715 pixels (Companion or APK)
An Image 200 x 350 pixels is reported as 200 x 350

The Canvas is not the best for line drawings but a chart drawn on it should look good on a high-res phone. For example, see the project "GaugeGenerator" in the Gallery.
It's important to give the Canvas fixed dimensions (pixels) for a chart - so verify the Screen Size, then set the Canvas size. It is acceptable to have an oversized Canvas in a Scroll Arrangement.

ScreenSizeTest.aia (7.0 KB)

Edit: On my website:

Thanks so much Chris for your help!

[Phone: One Plus 7 Pro
Processor: SnapdragonTM 855
Screen: Fluid AMOLED 6.67"
Android Version: 10
Build number: Oxygen OS 10.3.4.GM21AA
Model: GM1917]

I made the change to the screenttest program I posted before and enabled the clock after setting the length of the timer. I guess I didn't understand how the clock works and somehow assumed that it'd only start after the end of the initialize screen1 procedure... :frowning:
But nothing changed regardind the screen size numbers. I got the same numbers, exactly the same, bot for fixed and responsive sizing.
I then compiled your example (by the way thanks for it) and got the same results, as if it is reporting dp units and not pixels as in your case. I wonder if there is a switch or something else in the mit app inventor to switch that. Alternatively it may be a switch that operates at run time and it reacts differently to my One Plus 7 Pro than it does to your phone... Or it may be I have no clue what is going on...
Here is the screen,

Here is a link to my screentest app in case it is useful to anybody: screentest.aia

Hi again

See the project "GaugeGenerator" in the Gallery. I think it shows the use of the Canvas really well.

Yes, it does, but using the Gallery was not my problem.
After all these interactions I still have no clue how to access the full resolution of smart phones while charting data. Only the dp, which is a very poor alternative.
But now, I am colliding against another problem, how to keep building my chart while the application goes into the the background.

Hi Julio

App Inventor does not support Android Background Services, but it depends on the duration, because the App can be kept 'alive' instead. There is an AI2 compatible extension offering Background capability but I do not know if it can deliver what you need:

I see you are asking the same question/s on Kodular as well. This will incur the wrath of users on both forums for duplication of effort.

Pick an App Inventor variant, and stick to it, they are all different, and what works on one, may not work on another.

Leaving topic open for now.

Sorry, didn't know if was the wrong thing to do given that they are different environments.
I am asking these questions to decide which one to pick.
Marked the first answer as a solution, I am talking with the developer and will add another solution.

Thanks! I am already in touch with the developer Atom Developer of the solution that you mention and it seems it will work. There is a bunch of feedback and discussion about it in the Kodular site.
As an addition, other suggestions that I received were:
1.- Keep apk alive using keepalive
2.- Disable battery saving for the apk
3.- Make the apk clock timer based and program the timer to always run
4.- No solution found for accessing the full resolution of the high density screen phones

I don't think you can improve the Canvas (if it needs improvement?) from the App side. It's an Android component. You might want to look into using an HTML Canvas in a Web View component.

No idea how to do that, could you point me in the right direction? A simple example would be great! Thanks!

If you have no idea, you will need to understand the basics of HTML, CSS and javascript first, since they are all necessary to draw a Chart. It's not difficult to pick up and the best place to start is:

App Inventor can communicate with javascript code running in an HTML page viewed in a WebView Component. The Help:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.