cordova-plugin-devicedetector
v1.0.6
Published
Cordova Plugin to detect device type (TV, Phone, Tablet, etc.)
Maintainers
Readme
THIS PLUGIN IS WORKING & MAINTAINED
Device Detector
This plugin provides functionality to detect the device type.
Using
Create a new Cordova Project
$ cordova create hello com.example.helloapp HelloInstall the plugin
$ cd hello
$ cordova plugin add cordova-plugin-devicedetectorEdit www/js/index.js and add the following code inside onDeviceReady
try {
DeviceDetector.Detect(function(Detector) {
console.log('Detector => ', Detector);
}, function(error) {
console.error('Detector error => ', error);
});
} catch (e) {
console.error('DeviceDetector error => ', e);
}Plugin return teh following response via DeviceDetector.Detect
{
Detector.isTV ("true"/"false"), is true if UI_MODE_TYPE_TELEVISION is detected in Configuration
Detector.isTelevision ("true"/"false"), is true if PackageManager.FEATURE_LEANBACK is detected in hasSystemFeature()
Detector.isTypeTelevision ("true"/"false"), is true if "android.hardware.type.television" is detected in hasSystemFeature()
Detector.isLeanback ("true"/"false"), is true if "android.hardware.television" is detected in hasSystemFeature()
Detector.isAndroidTv ("true"/"false"), is true if "com.google.android.tv" is detected in hasSystemFeature()
Detector.isBox ("true"/"false"), is true if manufacturer of the BOXES is detected
Detector.isBoxTv ("true"/"false"), is true if "android.hardware.ethernet" is detected in hasSystemFeature()
Detector.isFireTV ("true"/"false"), is true if "amazon.hardware.fire_tv" is detected in hasSystemFeature()
Detector.isTablet ("true"/"false"), is true if Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_XLARGE or getConfiguration().smallestScreenWidthDp >= 600
Detector.isPhone ("true"/"false"), is true if "android.hardware.telephony.gsm" is detected in hasSystemFeature()
}