Skip to content

Commit

Permalink
[PowerManagement] update for license and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
viras committed May 20, 2013
1 parent 5c2a978 commit c18fd30
Show file tree
Hide file tree
Showing 4 changed files with 750 additions and 29 deletions.
42 changes: 16 additions & 26 deletions Android/PowerManagement/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,34 @@ It should be used for applications which keep running for a long time without an
For details on power functionality see:

* Android: [PowerManager](http://developer.android.com/reference/android/os/PowerManager.html)
* iOS: [idleTimerDisabled](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instp/UIApplication/idleTimerDisabled)
* WindowsPhone: [UserIdleDetectionMode](http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.phoneapplicationservice.useridledetectionmode%28v=vs.105%29.aspx)

Installation
Platforms
---------
Copy the **PowerManagement.java** file to your *src/org/apache/cordova/plugin* directory.
For all platforms copy the *PowerManagement.js* file to your applications "www" folder and load it using the according HTML code.
`<script type="text/javascript" charset="utf-8" src="lib/cordova/powermanagement.js"></script>`

Copy the **powermanagement.js** file to your *assets/www/js* directory.
### Android
Copy the *PowerManagement.java* file to your *src/* directory.

Edit your **AndroidManifest.xml** and add the following permission:
Edit your *AndroidManifest.xml* and add the following permission:
`<uses-permission android:name="android.permission.WAKE_LOCK" />`

Edit your **res/xml/config.xml** and add the following plugin:
In addition you have to edit your *res/xml/plugins.xml* file to let Cordova know about the plugin:
`<plugin name="PowerManagement" value="org.apache.cordova.plugin.PowerManagement"/>`

Usage
---------

Add this script tag to your **index.html** file, *after* calling your Cordova .js file:
`<script type="text/javascript" charset="utf-8" src="js/powermanagement.js"></script>`

Add the following code to your app's .js file, inside the function called by [deviceready](http://docs.phonegap.com/en/2.0.0/cordova_events_events.md.html#deviceready):
<pre>
var powerman = window.plugins.powerManagement;
</pre>
### iOS
Copy the *PowerManagement.h* and *PowerManagement.m* files to your projects "Plugins" folder.

There are three available methods to call:
Add the PowerManagement plugin to the *Cordova.plist* file (to the Plugins list). Both Key and Value are "PowerManagement".

<pre>powerman.acquire(successCallback, failureCallback)</pre>
Acquires a 'wake-lock', preventing the device screen from going to sleep.

<pre>powerman.dim(successCallback, failureCallback)</pre>
Acquires a partial 'wake-lock', allowing the screen to dim but preventing the device from going to sleep.

<pre>powerman.release(successCallback, failureCallback)</pre>
Release an acquired 'wake-lock'. Device able to sleep again.
### WindowsPhone
Copy the *PowerManagement.cs* file to your projects "Plugins" folder.

License
---------
Copyright (C) 2011-2012 Wolfgang Koller
=======
Copyright (C) 2011-2013 Wolfgang Koller

This file is part of GOFG Sports Computer - http://www.gofg.at/.

Expand Down
Loading

0 comments on commit c18fd30

Please sign in to comment.