- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I have created accelerometer example using accelerometer object and its method. It works properly in emulator but not in phone. Please reply as soon as possible.The below function is called on window onload. My code is below :
function init()
{
try
{
if(intel.xdk.accelerometer)
alert("accelerometer is supported");
else
alert("accelerometer is not supported");
intel.xdk.accelerometer.getCurrentAcceleration(
function(acceleration)
{
document.getElementById("text").innerHTML = 'Acceleration X: ' + acceleration.x + '\n' + 'Acceleration Y: ' + acceleration.y + '\n' + 'Acceleration Z: ' + acceleration.z + '\n' + 'Timestamp: ' + acceleration.timestamp + '\n';
});
}
catch(e)
{
alert('catched');}
};
Thanks & Regards,
Anjali Paria.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is your init() function being called after onDeviceReady has fired?
You should use the Cordova version of the accelerometer of the plugin, not the intel.xdk version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend using the Accelerometer (device-motion) Cordova plugin. You can find more information at https://github.com/apache/cordova-plugin-device-motion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anjali, the xdk plugins are no longer actively maintained. We recommended using the device-motion cordova plugin like Elroy pointed out. You can also refer to the Hello Cordova sample (ships with the XDK) for an example.
js file with accelerometer code: https://github.com/gomobile/sample-hello-cordova/blob/master/www/js/cordova-acc.js
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page