Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.os.PowerManager;

public class Main {
    private static PowerManager.WakeLock wakeLock;

    public static PowerManager.WakeLock acquireLock(Context context) {
        if (wakeLock == null || !wakeLock.isHeld()) {
            PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TT");
            wakeLock.setReferenceCounted(true);
            wakeLock.acquire();
        }
        return wakeLock;
    }
}