Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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();
    }
}