I tried to install this plugin for android. But it didn't work :in my index.html
function acquire() {
cordova.require('cordova/plugin/powermanagement').acquire(
function() { alert( 'hooray' ); },
function() { alert( 'oh no!' ); }
);
};
I have no alert :s
. I put in the www folder ;
<script type="text/javascript" charset="utf-8" src="lib/cordova/powermanagement.js"> </script>
then , in my AndroidManifest.xml:
<uses-permission android:name="android.permission.WAKE_LOCK" />
and in my config.xml
<plugin name="PowerManagement" value="org.apache.cordova.plugin.PowerManagement"/
what is wrong in my code?
Thanks.
Aurelie
Best Answer
I can't see anything wrong with the code you posted. What version of Phonegap are you using?
I had to update the PowerManagement plugin on github to get it working with Cordova 2.8.0. I also extended it to be able to acquire a partial wakelock. You can download my Eclipse project containing the updated plugin here.
Here's the updated code for use with Cordova 2.8.0:
PowerManagement.java
powermanagement.js
index.html (for testing)