Back to project page issue-parser.
The source code is released under:
GNU General Public License
If you think the Android project issue-parser listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.dom.drupalit.backgroundservice; import android.app.IntentService; import android.content.Context; import android.content.Intent; import android.os.PowerManager; // w ww . j a va2 s . co m abstract public class WakefulIntentService extends IntentService { abstract void doInBackground(Intent intent); public static final String LOCK_NAME_STATIC="de.dom.dupalit.backgroundservice.AppService.Static"; private static PowerManager.WakeLock lockStatic=null; public static void acquireStaticLock(Context context) { getLock(context).acquire(); } synchronized private static PowerManager.WakeLock getLock(Context context) { if (lockStatic==null) { PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE); lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC); lockStatic.setReferenceCounted(true); } return(lockStatic); } public WakefulIntentService(String name) { super(name); } @Override final protected void onHandleIntent(Intent intent) { try { doInBackground(intent); } finally { getLock(this).release(); } } }