android 黑屏状态下,开屏代码

public class WakeUpScreen extends Activity {
    PowerManager.WakeLock wakeLock;
    String TAG="started";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
        if( !pm.isScreenOn() )
        {
            wakeLock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.SCREEN_DIM_WAKE_LOCK, this.getClass().getCanonicalName());
            wakeLock.acquire();

                keyguardLock.disableKeyguard();
        }else{
            keyguardLock.reenableKeyguard();
        }
        Intent intent=new Intent();
        intent.setClass(this, AgainstTheft.class);
        startActivity(intent);
        this.lockScreen();
    }

    @Override
    protected void onPause() {
        super.onPause();
        wakeLock.release();
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();
    }
}

你可能感兴趣的:(android,String,service,Class)