Blog - Tag: device-PPI
How to Calculate the Device PPI
Written by mobilewidgets on date 22 September 2010 in Tips.
In the mobile phones context, PPI (pixels per inch) is a measurement of the resolution of devices screens. A higher PPI means better/clearer images. PPI can also be used to identify devices.
The following Javascript code presents a method to calculate the PPI and to identify the device:
function getPPI(){
var DOM_body = document.getElementsByTagName('body')[0];
var DOM_div = document.createElement('div');
DOM_div.style.width = "1in";
DOM_div.style.visibility = "hidden";
DOM_body.appendChild(DOM_div);
var ppi = document.defaultView.getComputedStyle(DOM_div, null).getPropertyValue('width');
DOM_body.removeChild(DOM_div);
return parseInt(ppi, 10);
}
var ppi = getPPI();
var device = '';
switch(ppi) {
case 265: device = 'Samsung ...
Recent entries
Popular entries
-
Vodafone sponsors mWomen Base of the Pyramid App Challenge
0 comments -
London Ajax User Group Happening - Event Review
0 comments -
Test your applications on real Vodafone devices in real time!
3 comments -
Developer resources, we'd like your input
12 comments -
Test your apps on the latest Android devices
0 comments
Tags
- 3d
- accessibility
- accessibility awards 2011
- ajax
- andoid
- android
- api
- apigee
- aponomy
- app
- app-star
- appathon
- applications
- apps
- appselect
- appstore
- blackberry
- challenge
- charity
- code
- compatibility
- competition
- css
- css-media-queries
- developer
- developers
- device-PPI
- droidCon
- emerging
- emulator
- ericsson
- feedback
- finalists
- fowa
- geolocation
- gsam
- GSMA
- hackathon
- ies-media-queries
- inmobi
- java
- javascript
- jibemobile
- language
- localisation
- marketing
- markets
- mef
- metadata
- mobandroid
- mobie
- mobile
- mobileclicks
- moyo
- mwc
- mwomen
- network
- nokia
- ovum
- perfecto
- perfectomobile
- picnic11
- privacy
- publishing
- qa
- qitcom
- rcs
- rim
- samsung
- smart
- smarter
- sony
- south-africa
- start-up
- start-ups
- startup
- store
- support
- survey
- symbian
- testing
- tips
- ue
- vmc2011
- vodacom
- vodafone
- vodafone-360
- vodafoneshop developer apps mobile
- wac
- webinar
- wholesale-applications-community
- widgets
- winawards
Categories
- Mobile Clicks 2011 6 entries
- Survey 2 entries
- The Internet of Things 0 entries
- Competition 27 entries
- Event 28 entries
- New Content 11 entries
- News 39 entries
- Publishing 11 entries
- Testing 9 entries
- Tips 30 entries
- Uncategorized 16 entries
- Webinar 4 entries
Archives
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
