android


Check android device density in html


How do I check device density of android device inside html page?
I tried below code but not working for android device -
if($(window).devicePixelRatio == 1) {
a1=a1+a1*5;
}
else if($(window).devicePixelRatio == 2) {
a1=a1+a1*10;
}
you can get device density by using javaScriptInterFace.
wv.addJavascriptInterface(new JavaScriptInterface(context),
"jsInterface");
public class JavaScriptInterface {
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
#JavascriptInterface
public float getDensity() {
return scale = mContext.getResources().getDisplayMetrics().density;
}
}
and in your html get density by javascript
var scale = jsInterface.getDensity();
0.75 means low density
1.0 means standard (medium) density
1.5 means high (large) density
2.0 means extra high density

Related Links

Is it possible to send HashMap as extra in adb shell am broadcast?
How to set value in ArrayList inside ArrayList?
Google People Api Implementation in android application
CWAC cam2 version 4.0 orientation issue
CheckBox checked on scroll automatically in ListView in android
how to create SQLite database in external folder like Whats app does in Android?
Making form on android studio
SQLite database : data folder persmission
setVisibleXRangeMaximum() and setVisibleYRangeMaximum() not working in MPAndroidChart
android - tablet not using values-sw600dp and layout-sw600dp folders
Error with Android gradle “Cause: startup failed: build file”
Change the system display size programatically Android N
Android Camera Sticker overlay and merge both images to one
Error running exec(). Command
Dropdown spinner items list by pressed on linearlayout
Listview refresh while fetching data from server

Categories

HOME
url-redirection
alexa-skills-kit
google-spreadsheet
swt
static
mstest
pdfbox
access
newrelic
simulink
interpolation
tvos
fabric.io
jquery-ui-sortable
openpyxl
enthought
siddhi
tput
onedrive-api
shared-libraries
eip
flatpak
entitymanager
html5-appcache
git-extensions
soci
sigma.js
solrcloud
google-maps-autocomplete
blade
imageresizer
displaytag
ms-access-2003
inversion-of-control
comparable
sqsh
autodesk-designautomation
event-flow
weather
cognos-bi
dumpbin
hard-drive
navigator
xajax
openproject
jpad
z-notation
health-monitoring
opensmpp
azure-arm
visa
angular-http
x++
ovf
openal
builder
hammer.js
rserve
identification
spring-data-couchbase
skin
payload
cpu-cache
filenet
rsa-archer-grc
mapxtreme
preprocessor
flex4.6
hclust
tooleap
clipboard.js
hadoop-partitioning
html-to-pdf
findfirst
false-sharing
qbxml
toast
relativelayout
sapi
sciruby
rewrite
microsoft-reporting
visual-sourcesafe-2005
mod-proxy
uncompress
snoop
matlab-deployment
uvc
osc
diff3
structuremap3
teaspoon
ignite-ui
codeplex
grails-domain-class
maven-scm
breakout
inputmismatchexception
observium
apache-abdera
preload
idn
monotouch.dialog
jquery-blockui
xcode3.2
usertype
entitydatasource
cdonts
qglwidget
silent
asynchronous-wcf-call
escrow
ifilter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App