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

How to swipe and switch between two images?
Android Mapview show white tiles without any map
How can i save audio from speech recognition API?
Navigation tabs with fragments to which to add another fragment
Get the category of any app programetically in Android?
PhoneGap for Android - Connect to Database
Passing data from a Service
Building cocos2d-x android project failed: Unknown EABI object attribute 44
Add a layout in a view
Android Programming ViewPager from a GridView
Monitoring wifi state change since boot time in Android
Writing arbitrary metadata to EXIF in Android
Screen Size of VideoView is changing When playing video in VideoView Android
Change EditText via slide/scroll/drag and normal input when only just touched
Map Directions API choice
SQLite and storing images

Categories

HOME
uml
scikit-learn
polymer
string
pagination
pda
case
rsa
sitecore
gradient
entity-framework-core
square
onclick
polling
tvos
bing-maps
endeca
favicon
scrolltop
flatpak
firefox-addon
dimensional-modeling
vuejs
google-picker
apache2.4
visual-glitch
squashfs
backpack-for-laravel
event-store
game-theory
data.stackexchange.com
maze
slidetoggle
intersystems-cache
carrierwave
testcomplete
aws-codecommit
cognos-bi
android-sugarorm
instantiation
carriage-return
fiware-cygnus
reason
connection-pool
urlsession
spring-mvc-test
setup.py
resolution
azure-arm
watchface
logback-groovy
placeholder
reportservice2010
manova
zenhub
pair-programming
oracleclient
jqchart
sundials
cup
bbpress
flyout
objectscript
reachability
cvxpy
pytables
reporting-services-2012
neon
windows-azure-queues
dimension
gogs
angular-ui-typeahead
custom-errors
toran-proxy
android-launcher
apache-commons-daemon
uvc
cryptographichashfunction
exceldatareader
addressing-mode
structuremap3
spy++
openargs
android-usb
mvc-editor-templates
dolby-audio-api
insert-id
veracity
dajaxice
iboutlet
paginator
virtualpathprovider
node-redis
event-receiver
mtu
maven-1
binomial-heap
addchild
zen
opml
burndowncharts
lalr
purepdf
wcf-instancing
visualj#
asynchronous-wcf-call
xpsdocument
entitykey

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