I'm running android 4.4.4 on a 52" touchscreen mounted in portrait orientation. Even when requesting the desktop site to the browser, because of the portrait orientation, I get the responsively scaled version of many sites. I believe that this is related to the system reporting it's orientation as portrait. I have adjusted the resolution in various configurations but still get the scaled display. The zoom and scale settings have been disabled in the browser too.
I can fix this on the sites that I manage programmatically, but I would rather solve the problem on the device since I don't manage all the sites. Is there a way I can forge reported resolution or reported orientation to prevent this behavior? Any other ideas as to how to resolve this? The OS is rooted, so anything goes.
There is an experimental API for device orientation, but most developers calculate it from the provided browser properties, so you can't really fake that from your side.
But, I'm not sure if the problem you're running in to is not one of orientation or of the pixel ratio. On most devices the resolution is halved to provide double density displays. This means that even though you might request the full site and be on a screen that could reasonably render 1080 x 1920, because the browser expects to employ pixel doubling, it might only render it as if it were 540 x 960 and the over-sized elements are your screen being, essentially, waaaaaay too big, but proportionally correct.
If you're tethering to a phone you might see if there is a device specific method or app that overcomes this limitation. If you have installed directly on the firmware of a display, I would contact the manufacturer if it is supported.
Best of luck!
As far as I know, the 'orientation' is not reported. Just the window size is reported. You may be experiencing that some browsers will get the desktop layout but then scale up the font size to try to make it more mobile friendly.
Related
My question assumes I know about the device's resolution and dpi and my monitor resolution and dpi. Also, the web page layout is fluid (everything expressed in percentages of em, as per w3c recommendations).
For example, let's say that in the mobile device I have a screen of 480x320 and a dpi of 192. My monitor has a dpi of 96, does that mean that I should see the same thing as in the mobile browser if I set my desktop's Chrome's dimensions at 960x640? If not, what factors should I account for?
No. You will see the same thing as you will see on the phone if you set chrome's dimensions at 480x320. Pixels are the same no matter whether you are viewing them on a phone, or on a desktop computer.
The DPI figure just tells you the RESOLUTION of the device. e.g. your computer has 96 pixels per inch and your phone has 192. Therefore, 480*320 will take up a bigger physical area on your computer than on your phone screen, although the output will (should be*) exactly the same.
*If you're using any scripts/code which checks for a Useragent and varies the output depending on whether it is a phone/browser/netbook/whatever then you'll need to take this into account. You can get chrome plugins which "spoof" Useragents, allowing you to look at a site as if you are a mobile device. If you're just literally using clever CSS and fluid layouts however you should be fine.
You can change the User-Agent string and emulate different mobile resolutions in the Chrome developer tools.
Open the developer tools with F12, click the gear icon in the lower right corner and open the User agent tab.
There's a difference between hardware pixels and normalized optical pixels, but it's complicated matter. I suggest reading more about it on QuirksMode or A list apart.
Yes you can, Simply Hit Ctrl++ you will see the difference, to zoom out use Ctrl--,
to Come to original State press Ctrl+0.
you can also Resize the window manually, this will change the fluid layout too.
How do I set up emulator for specific android device? I mean how to properly get Abstracted screen density and screen size? Is there any online resource which can provide info about these constants?
Ya, Google it for your answer.
This link here have a few common phones.
See if it matches your needs.
http://mobile.tutsplus.com/tutorials/android/common-android-virtual-device-configurations/
In this wiki page, you can get some resolution and density.
For example, samsung phones:
http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density#Samsung
Yes, it's called Google and math:)
Goole the name of your target device. Get its specs, resolution width and height and screen size. Then the density, which is expressed in dots(pixels) per inch is obtained by simply calculating the total number of pixels for the given screen size and reporting that to one square inch.
At any rate, don't get your hopes high about using the emulator to actually (realistically) simulate real devices. The emulator is slow as hell (to the point where a blank OpenGL surface will be drawn at 2 FPS). Your best bet is to get the actual physical device you need. Second best is to use Android x86 though that one has other issues (but runs generally faster than the default emulator).
I am developing a mobile website, and I've come across an interesting issue.
I'm testing on my desktop, as well as on my Motorola Droid (Android 2.2). I have media queries set up to load 3 different stylesheets (320px wide, 480px wide, and 640px wide). I noticed that my Droid is loading the 320px stylesheet despite having a 480x854px screen. I set up a little JS to find out what the screen width is, and it's reporting 320px.
Does the Android browser run in MDPI on HDPI screens? It's scaling the 320px properly to fill the screen, but I'm a little confused why this is happening.
Also, I do have <meta name="viewport" content="width=device-width"> on my page, so that is not the issue.
Many OEMs have chosen to set their default browser viewport dimensions based on those of the iPhone (or similar resolutions) despite having an altogether different resolution. Apple had a similar problem with the release of the 'retina display' on the iPhone 4 where the spec sheet states 640px across, but screen.width will return 320px when is set.
As #omermuhammed mentioned base your logic on screen.width, CSS #media queries AND/OR device detection using WURFL or DeviceAtlas.
The following article may also be of interest in helping to clarify the issue:
A pixel is not a pixel is not a pixel by #ppk
http://www.quirksmode.org/blog/archives/2010/04/a_pixel_is_not.html
I don't know in context of Android Browser, but I have seen handsets where Android reported wrong screen size. I would recommend basing your logic on a combination of user agent string AND screen resolution. This way you can detect this handset and handle differently, and use normal mechanisms with others.
I have noticed a few issues with getting screen.width and screen.height on Android 4.2.
Dimensions are not updated to reflect the orientation of the device.
You can correct this if you wish to by first getting orientation, then switching the values accordingly.
http://menacingcloud.com/?c=orientationScreenWidth
http://davidwalsh.name/orientation-change (nice matchMedia usage)
OS user interface elements are subtracted from the actual device screen dimensions.
E.g. nexus 7 screen is 1280x800, 1205x800 is reported. 75px for the OS buttons.
Ideally (in my opinion), the values should be reported in CSS pixels, not device pixels.
E.g. nexus 7, CSS viewport is set to 600px in portrait, but screen.width reports 800px. So DPR is approx 1.33
Overall, screen.width and screen.height are not very reliable (iOS has orientation issues as well).
I'll hopefully re-edit this answer with more detail soon.
Using Adobe AIR for Android, I'd like to find a way to distinguish a phone from a tablet. The closest I can find is detecting the dpi. (My phone dpi is 254, my tablet is 149) but is that going to be reliable or is there a better way?
(I've been using stackoverflow for a while but this is my first post - yippee!!)
but is that going to be reliable
Absolutely not. A T-Mobile G1 would be a tablet by that measure.
is there a better way?
Frankly, you should not be caring whether an Android device is a telephone, tablet, television, toaster, telescope, or toilet.
You should be caring about characteristics and capabilities.
For example, if you are thinking about tablets in terms of screen size, use <supports-screens> and the -large and -xlarge resource sets (e.g., res/layout/ for normal stuff and res/layout-large/ for larger screen sizes).
Or, if you are thinking about tablets in terms of whether or not you can place a phone call, use <uses-feature> and hasSystemFeature() on PackageManager.
Whether a device is a tablet or not could mean...
One.... Is it running the Honeycomb tablet version (Android 3.0) ? You can use System.getProperty() to get this information.
or
Two....Is it tablet sized? i.e. is the screen a larger size? But bear in mind some tablets are not that big. Best way to handle these is separate resources for each device size.
I'd say in general it's a bad idea to try to define Android tablets into specific groups, as there are many varieties now and a LOT more are coming. So usually best to build your app so it handles different screen sizes, different OS versions, and different features being available or absent (e.g. GPS, keyboard etc).
cdotspace, don't worry about the real dpi, you only need to get virutal dpi:
int virtual_dpi=webview1.getResources().getDisplayMetrics().densityDpi;
Virutal dpi means dots per virtual inch.
For example, the htc desire hd's real width is 2.21 inches, but its virutal width is still 2 inches, the galaxy tab 10.1's real width is 5.35 inches(portrait orient), but its virtual width is 5 inches.
int portrait_width_pixel=Math.min(this.getResources().getDisplayMetrics().widthPixels, this.getResources().getDisplayMetrics().heightPixels);
int dots_per_virtual_inch=this.getResources().getDisplayMetrics().densityDpi;
float virutal_width_inch=portrait_width_pixel/dots_per_virtual_inch;
if (virutal_width_inch<=2)
{//is phone
}
else
{//is tablet
}
I'm trying to alter the default screen resolution of the Android emulator (and by extension, the Android device) to work at 1700x1200. In other words, I need the screen to be able to display unique points over that range.
I have set the dimensions in my layout file, yet the device still defaults to 320x480. I've set different dpi densities, but to no avail.
Any help would be great, even just a direction to explore.
EDIT: Thanks for the two responses. I guess my question wasn't clear - I understand that the top resolution for the device is fixed, but I need to scale the screen to display with finer granularity than just 640X850 (which I believe is the highest resolution). I understand you can set dpi density from 120-240, but I need to know how to set the scaling functionality to simulate a screen of 1700x1200. My guess is that it will have to be done by my code, but I would prefer for the platform to auto-scale it down for me. This may not be possible, but I just wanted to check.
Using Android SDK 2.0 or 2.1 you can create an AVD with a custom resolution. If you want you can also run the emulator with the -skin argument, for instance emulator -skin 1700x1200 and you'll get what you want.
May be i'm not completely understand that. You want physical device such as ADP1 phone for example, to have 1700x1200 ? If it that you want - i have some bad news - if you look at any device spec you'll see resolution listed. It's there because it characteristic of physical screen. It can't be changed.