Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.os.PowerManager; public class Main { /** * The Wake lock. */ private static PowerManager.WakeLock wakeLock; /** * Hold wake lock. * * @param context * the context */ public static void holdWakeLock(Context context) { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock"); wakeLock.acquire(); } }