What is screen Scale value for Lumia 950 and 950 XL? - winrt-xaml

Since I don't have any of the mentioned phones with Windows 10 Mobile, can someone, who have Lumia 950 or 950 XL , run the following few lines of code in blank UWP application project to get the Scale value out of this device (to figure out effective resolution eventually):
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
// ### snipped start ###
var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues;
string scale;
if (qualifiers.TryGetValue("Scale", out scale))
{
System.Diagnostics.Debug.WriteLine(scale);
}
// ### snipped end ###
}
}
Please post the integer number from the output window as an answer - will be much appreciative!
PS. Suspecting that it should be 400 for 950 and 450 for 950 XL, but would like to be sure.

OK, in case anybody will look for it later - the scale is 400 for Lumia 950, thanks to colleague, who bought it recently.

Related

Density of screen in iOS and Universal WIndows App

Hi I need to know the density of screen in windows 10/8/8.1 and iOS.
I got screen density in Android using DisplayMetrics but I find no such option/property available in UWP and iOS.
So Is there any property through which I can get screen density in UWP and IOS.
UPDATE - June 8th 2018
Xamarin has released Xamarin.Essentials!
Xamarin.Essentials provides developers with cross-platform APIs for their mobile applications.
Android, iOS, and UWP offer unique operating system and platform APIs that developers have access to all in C# leveraging Xamarin. Xamarin.Essentials provides a single cross-platform API that works with any Xamarin.Forms, Android, iOS, or UWP application that can be accessed from shared code no matter how the user interface is created.
https://github.com/xamarin/Essentials
You can now query the device's display information without having to manage all of the individual platform code pieces.
Device Display Information - https://learn.microsoft.com/en-us/xamarin/essentials/device-display
How-To:
Add a reference to Xamarin.Essentials in your class:
using Xamarin.Essentials;
The following information is exposed through the API:
// Get Metrics
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
// Orientation (Landscape, Portrait, Square, Unknown)
var orientation = mainDisplayInfo.Orientation;
// Rotation (0, 90, 180, 270)
var rotation = mainDisplayInfo.Rotation;
// Width (in pixels)
var width = mainDisplayInfo.Width;
// Height (in pixels)
var height = mainDisplayInfo.Height;
// Screen density
var density = mainDisplayInfo.Density;
Useful Links:
(Github) Xamarin.Essentials - https://github.com/xamarin/Essentials
(Blog) Xamarin.Essentials - https://blog.xamarin.com/xamarin-essentials-cross-platform-apis-mobile-apps/
(Docs) Getting Started with Essentials - https://learn.microsoft.com/en-us/xamarin/essentials/get-started
Original Post (Before Xamarin.Essentials existed)
Below, I'm storing the specific OS's screen details in static vars, located in the Xamarin Forms App class
These all appear to work in my testing.
(copy/pasted from my github page - https://github.com/mattregul/Xamarin_Screensize)
Android (MainActivity.cs) - Jump to Github Page
// Store off the device sizes, so we can access them within Xamarin Forms
// Screen Width = WidthPixels / Density
// Screen Height = HeightPixels / Density
App.DisplayScreenWidth = (double)Resources.DisplayMetrics.WidthPixels / (double)Resources.DisplayMetrics.Density;
App.DisplayScreenHeight = (double)Resources.DisplayMetrics.HeightPixels / (double)Resources.DisplayMetrics.Density;
App.DisplayScaleFactor = (double)Resources.DisplayMetrics.Density;
iOS (AppDelegate.cs) - Jump to Github Page
// Store off the device sizes, so we can access them within Xamarin Forms
App.DisplayScreenWidth = (double)UIScreen.MainScreen.Bounds.Width;
App.DisplayScreenHeight = (double)UIScreen.MainScreen.Bounds.Height;
App.DisplayScaleFactor = (double)UIScreen.MainScreen.Scale;
Note In all Windows examples screensize is the root project namespace
UWP (App.xaml.cs) - Jump to Github Page
// You decided which is best for you...
// Do you want Size of the App's View
// or
// Do you want the Display's resolution
// ######################################
// Size of App's view
screensize.App.DisplayScreenHeight = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Height;
screensize.App.DisplayScreenWidth = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;
// Size of screen's resolution
//screensize.App.DisplayScreenWidth = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().ScreenHeightInRawPixels;
//screensize.App.DisplayScreenHeight = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().ScreenWidthInRawPixels;
// Pixels per View Pixel
// - https://msdn.microsoft.com/en-us/windows/uwp/layout/design-and-ui-intro#effective-pixels-and-scaling
// - https://msdn.microsoft.com/en-us/windows/uwp/layout/screen-sizes-and-breakpoints-for-responsive-design
screensize.App.DisplayScaleFactor = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
Windows Phone 8.1 (App.xaml.cs) - Jump to Github Page
// Size of App's view
screensize.App.DisplayScreenHeight = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Height;
screensize.App.DisplayScreenWidth = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds.Width;
// Pixels per View Pixel
// - https://msdn.microsoft.com/en-us/windows/uwp/layout/design-and-ui-intro#effective-pixels-and-scaling
// - https://msdn.microsoft.com/en-us/windows/uwp/layout/screen-sizes-and-breakpoints-for-responsive-design
screensize.App.DisplayScaleFactor = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
Windows 8.1 (App.xaml.cs) - Jump to Github Page
// Size of App's view
screensize.App.DisplayScreenHeight = Window.Current.Bounds.Height;
screensize.App.DisplayScreenWidth = Window.Current.Bounds.Width;
screensize.App.DisplayScaleFactor = 1; // No scaling here? If you find a scaling for Windows 8.1, please let me know :)
Xamarin Forms Page (App.cs) - Jump to Github Page
namespace screensize
{
public class App : Application
{
public static double DisplayScreenWidth = 0f;
public static double DisplayScreenHeight = 0f;
public static double DisplayScaleFactor = 0f;
public App()
{
string ScreenDetails = Device.OS.ToString() + " Device Screen Size:\n" +
$"Width: {DisplayScreenWidth}\n" +
$"Height: {DisplayScreenHeight}\n" +
$"Scale Factor: {DisplayScaleFactor}";
// The root page of your application
var content = new ContentPage
{
Title = "Xamarin_GetDeviceScreensize",
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
HorizontalTextAlignment = TextAlignment.Center,
FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
Text = ScreenDetails
}
}
}
};
MainPage = new NavigationPage(content);
}
}
}
This list lists the ios device dpi information. You can also use GBDeviceInfo thrid-party tool to get the screen density for IOS device like this [GBDeviceInfo deviceInfo].displayInfo.pixelsPerInch;
IOS:
iPhones
iPhone 1/3G/3GS 320 x 480 163 ppi
iPhone 4/4S 640 x 940 326 ppi
iPhone 5/5C/5S 640 x 1136 326 ppi
iPhone 6/6S 750 x 1334 326 ppi
iPhone 6 Plus/6S Plus 1080 x 1920 401 ppi
Without downsampling: 1242 x 2208 461 ppi
Except for the 6th generation (= 5th) iPod touch,
all the models are equal to their iPhone counterparts
iPads
iPad 1/2 768 x 1024 132 ppi
iPad 3/4/Air/Air 2 1536 x 2048 264 ppi
iPad Mini 1 768 x 1024 163 ppi
iPad Mini 2/3/4 1536 x 2048 326 ppi
iPad Pro 2737 x 2048 264 ppi
Apple Watches
Apple Watch 38 mm 272 x 340 326 ppi
Apple Watch 42 mm 312 x 390 326 ppi
I found API in the UWP to retrieve the device dpi. Windows.Graphics.Display.DisplayInformation. You can try it.

Move MKMapView legal label on rotation

I have an MKMapView with an iAd banner on top. Due to this iAd Banner covering the MKMapView's legal label, it is moved. The following code is performed in viewDidLayoutSubviews:
NSLog(#"ViewDidLayoutSubviews called");
UILabel *attributionLabel = [self.mapView.subviews objectAtIndex:1];
if (adBannerViewFrame.origin.y < attributionLabel.frame.origin.y) {
NSLog(#"Banner Y coordinate: %f", adBannerViewFrame.origin.y);
CGRect legalFrame = attributionLabel.frame;
legalFrame.origin.y -= IAD_BANNER_HEIGHT;
attributionLabel.frame = legalFrame;
NSLog(#"Legal y: %f", legalFrame.origin.y);
NSLog(#"Legal x: %f", legalFrame.origin.x);
NSLog(#"Legal width: %f", legalFrame.size.width);
NSLog(#"Legal height: %f", legalFrame.size.height);
}
When I switch from the View Controller containing the map to another VC and back again, the code above works perfect, regardless of orientation; however, when rotating the devices without switching VCs, the legal label disappears on rotation and don't come back until I switch back and fourth between VCs again. The NSLogs print out the exact same for both rotation and VC switching:
ViewDidLayoutSubviews called
Banner Y coordinate: 902/646(rotation dependent)
Legal x: 882/626(rotation dependent)
Legal y: 11
Legal width: 48
Legal height 11
Despite everything looking the same, the label is gone after rotating (not sure if it is moved out of the view or if it actually disappears)
The iAd Banner is reloaded in ViewDidAppear (which is called when VCs are switched back and fourth). However, since the NSLogs print the same for both scenarios, I cannot see how it should make any difference. To be sure, I tried to reload the iAd Banner in ViewDidLayoutSubviews as well, with no different result than before. Anyone experienced anything similar or know how to fix this?
For anyone encountering the same issue, I found a solution. The workaround was to schedule a timer with 0 seconds and have the timer call the method executing the code above.
[NSTimer scheduledTimerWithTimeInterval:0 target:self selector:#selector(test) userInfo:nil repeats:NO];
I assume that something was not completely finished when viewDIDlayoutSubviews was called and that adding a timer (which is not 100 % accurate and will therefore not start immediately), allowed the unknown remaining stuff to complete before the code in the question was executed.

How to delay an animated sprite in Andengine?

I have an animated Sprite that is drawn on the screen when I press the button. However, I want to the animation to start after 5 seconds. Technically, the ver first PNG in the "animation set" is shown and the animation starts after 5 seconds.
I have tried to used the DelayModifier as follows, but without luck:
mySprite.registerEntityModifier(new DelayModifier(500)); //doesn't work
I would appreciate your input.
I found the solution to my problem from this tutorial: http://www.andengine.org/forums/tutorials/using-timer-s-sprite-spawn-example-t463.html
The idea was to use a TimeHandler and not a DelayModifier.
actually , you can do it with a delaymodifier too , like this
DelayModifier dMod = new DelayModifier(5f){
#override
public void onModifierFinished(IModifier arg0, IEntity arg1) {
mySprite.animate(300);
}
}
mySprite.registerEntityModifier(dMod);

PlayN Fullscreen

I don't know why it is not working.
I want to start my game in fullscreen on desktop (Java).
Code
#Override
public void setToFullScreen() {
int screenHeight = graphics().screenHeight();
int screenWidth = graphics().screenWidth();
log().debug("ScreenHeight: " + screenHeight);
log().debug("ScreenWidth: " + screenWidth);
graphics().setSize(screenWidth, screenHeight);
}
The log says:
ScreenHeight: 480
ScreenWidth: 640
My possible resolution would be full hd - any ideas?
PlayN is not made for Java-fullscreen-mode.
The Java-Applet view is made for debugging reasons for all other platforms.
If you want to use fullscreen mode, you probably need to change the PlayN-java-sourcecode.
You maybe have to use the method
java.awt.GraphicsDevice.setFullScreenWindow(...)
The commands
graphics().screenWidth();
graphics().screehHeight();
give you the size of the playn game window.
if you want to adjust the screen size to Full HD, you have to do it like this:
graphics().setSize(1920, 1080);
this will set the size of the playn window to 1920, 1080. Howerver, this does not set your game to full screen.
Don't know which version you are using, but in the bleeding edge (1.5-SNAPSHOT) those functions return the REAL screen resolution every time.

Nokia N97 realted to orientation

Myself shweta dodiya.I am facing problem with nokia N97 related to change orientation for my game application.
I am using J2me technology.I want to pause my application when i open my slider.
Thanks in advance
I don't know what code are you using, or are you using Canvas to draw the game on screen, or some other API that does that for you...
If you have something like this GameScreen extends Canvas and you use GameScreen object to draw and display the game, you need to add an override to sizeChanged method to it and check the new width (w) and the new height (h) of the GameScreen, and do the things you want in regards to that:
public void sizeChanged(int w, int h)
{
if(h > w) //NORMAL
{
drawGame();
if(paused) resumeGame();
}
else //LANDSCAPE
{
pauseGame();
drawPauseScreen();
}
}
This is a simple pseudo code, I hope you are getting the point. If statement is checking the relation between new width and the new height. If the phone is in landscape mode, H is less then W...

Resources