Bug 30285 - Xamarin Android Player reports incorrect values for xdpi and ydpi
Summary: Xamarin Android Player reports incorrect values for xdpi and ydpi
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin Android Player
Classification: Xamarin
Component: Player ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-05-20 18:52 UTC by Michael
Modified: 2015-07-20 09:48 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Michael 2015-05-20 18:52:58 UTC
Description: when using the android.util.DisplayMetrics class in native Android code (no Xamarin whatsoever) to obtain device display characteristics of a Xamarin Android Player device, the the xdpi and ydpi fields always seem to report 100 instead of the correct value. When doing the same experiment on a stock Android emulator, these fields report the correct values.
Steps to reproduce: in Eclipse, create a simple Hello World project for Android. Place the following code in the onCreate method of the MainActivity class:
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        TextView t = (TextView)findViewById(R.id.my_label);
        t.setText("X dpi: " + metrics.xdpi + "\nY dpi: " + metrics.ydpi);
Run the code on a Xamarin Android Player device and a stock Android emulator. Note that the values are incorrect on the former and correct on the latter.
Comment 1 Will Schaller 2015-06-03 09:46:17 UTC
Hi Michael,
We've confirmed the issue, but I'd like to get a sense of what kind of priority to consider this. It's our understanding that it's recommended these values aren't used, as they're often incorrect on some physical devices (see thread at: https://groups.google.com/forum/#!topic/android-developers/g56jV0Hora0). 

Is the fact that these are incorrect especially blocking to what you want to do?

Thanks,
Will
Comment 2 Mark Simpson 2015-07-20 09:48:19 UTC
As there has been no activity on this bug, I'm going to close. As Will has said, these are values that Google do not recommend using.