mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:42:53 +08:00
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
/**
|
|
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
|
* phone, etc.
|
|
* @constructor
|
|
*/
|
|
function Device() {
|
|
this.available = PhoneGap.available;
|
|
this.platform = null;
|
|
this.version = null;
|
|
this.name = null;
|
|
this.uuid = null;
|
|
this.phonegap = null;
|
|
|
|
var me = this;
|
|
PhoneGap.execAsync(
|
|
function(info) {
|
|
me.available = true;
|
|
me.platform = info.platform;
|
|
me.version = info.version;
|
|
me.uuid = info.uuid;
|
|
me.phonegap = info.phonegap;
|
|
},
|
|
function(e) {
|
|
me.available = false;
|
|
console.log("Error initializing PhoneGap: " + e);
|
|
alert("Error initializing PhoneGap: "+e);
|
|
},
|
|
"Device", "getDeviceInfo", []);
|
|
}
|
|
|
|
/*
|
|
* This is only for Android.
|
|
*
|
|
* You must explicitly override the back button.
|
|
*/
|
|
Device.prototype.overrideBackButton = function() {
|
|
BackButton.override();
|
|
}
|
|
|
|
/*
|
|
* This is only for Android.
|
|
*
|
|
* This resets the back button to the default behaviour
|
|
*/
|
|
Device.prototype.resetBackButton = function() {
|
|
BackButton.reset();
|
|
}
|
|
|
|
/*
|
|
* This is only for Android.
|
|
*
|
|
* This terminates the activity!
|
|
*/
|
|
Device.prototype.exitApp = function() {
|
|
BackButton.exitApp();
|
|
}
|
|
|
|
PhoneGap.addConstructor(function() {
|
|
navigator.device = window.device = new Device();
|
|
});
|