当前位置: 首页>>代码示例>>Java>>正文


Java PowerManager.newWakeLock方法代码示例

本文整理汇总了Java中android.os.PowerManager.newWakeLock方法的典型用法代码示例。如果您正苦于以下问题:Java PowerManager.newWakeLock方法的具体用法?Java PowerManager.newWakeLock怎么用?Java PowerManager.newWakeLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.PowerManager的用法示例。


在下文中一共展示了PowerManager.newWakeLock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.os.PowerManager; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get an instance of the SensorManager
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    // Get an instance of the PowerManager
    mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

    // Get an instance of the WindowManager
    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mDisplay = mWindowManager.getDefaultDisplay();

    // Create a bright wake lock
    mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
            .getName());

    // instantiate our simulation view and set it as the activity's content
    mSimulationView = new SimulationView(this);
    setContentView(mSimulationView);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:AccelerometerPlayActivity.java

示例2: wakeAndUnlock

import android.os.PowerManager; //导入方法依赖的package包/类
public static void wakeAndUnlock() {
    //获取电源管理器对象
    PowerManager pm = getPowerManager();

    //获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");

    //点亮屏幕
    wl.acquire(1000);

    //得到键盘锁管理器对象
    KeyguardManager km = getKeyguardManager();
    KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");

    //解锁
    kl.disableKeyguard();
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:18,代码来源:NotifyUtils.java

示例3: onConnected

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
    LocationRequest request = new LocationRequest();
    request.setInterval(mFirebaseRemoteConfig.getLong("LOCATION_REQUEST_INTERVAL"));
    request.setFastestInterval(mFirebaseRemoteConfig.getLong
            ("LOCATION_REQUEST_INTERVAL_FASTEST"));
    request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
            request, TrackerService.this);
    setStatusMessage(R.string.tracking);

    // Hold a partial wake lock to keep CPU awake when the we're tracking location.
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    mWakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");
    mWakelock.acquire();
}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:17,代码来源:TrackerService.java

示例4: onCreate

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_recorder);

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, CLASS_LABEL);
    mWakeLock.acquire();

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    //Find screen dimensions
    screenWidth = displaymetrics.widthPixels;
    screenHeight = displaymetrics.heightPixels;

    initHandler();

    initLayout();
}
 
开发者ID:feigxj,项目名称:VideoRecorder-master,代码行数:21,代码来源:FFmpegRecorderActivity.java

示例5: wakeAndUnlock

import android.os.PowerManager; //导入方法依赖的package包/类
private void wakeAndUnlock(boolean b)
   {
if (b)
{
    //获取电源管理器对象
    mPowerManager = (PowerManager)getApplicationContext().getSystemService(Context.POWER_SERVICE);
    //获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag
    mWakeLock = mPowerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
    //点亮屏幕
    mWakeLock.acquire();
    //得到键盘锁管理器对象
    mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
    mKeyguardLock = mKeyguardManager.newKeyguardLock("unLock");
    //解锁
    mKeyguardLock.disableKeyguard();
}
else
{
    //锁屏
    mKeyguardLock.reenableKeyguard();
    //释放wakeLock,关灯
    mWakeLock.release();
}}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:24,代码来源:dex_smali.java

示例6: wakeAndUnlock

import android.os.PowerManager; //导入方法依赖的package包/类
private void wakeAndUnlock(boolean b) {
    Log.i(TAG, "解锁亮屏?:" + b);
    if (b) {
        //获取电源管理器对象
        pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        //获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是调试用的Tag
        wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "bright");
        //点亮屏幕
        wl.acquire();
        //得到键盘锁管理器对象
        km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        kl = km.newKeyguardLock("unLock");
        //解锁
        kl.disableKeyguard();
        isWaked = true;
    } else {
        //锁屏
        kl.reenableKeyguard();
        //释放wakeLock,关灯
        wl.release();
    }
}
 
开发者ID:mcxtzhang,项目名称:miser-utils,代码行数:23,代码来源:ComeOnMoneyService.java

示例7: acquire

import android.os.PowerManager; //导入方法依赖的package包/类
public static void acquire(Context context) {
    if (wakeLock != null)
        wakeLock.release();

    PowerManager pm = (PowerManager) context
            .getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
            | PowerManager.ON_AFTER_RELEASE, "WakeLock");
    wakeLock.acquire();
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:11,代码来源:WakeLocker.java

示例8: onReceive

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    MediaPlayer mp = MediaPlayer.create(context, R.raw.ferry_sound);
    mp.start();
    PowerManager pm = (PowerManager)     context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My GlobalData");
    wl.acquire();
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    long[] s = { 0, 100, 10, 500, 10, 100, 0, 500, 10, 100, 10, 500 };
    vibrator.vibrate(s, -1);
}
 
开发者ID:atulgpt,项目名称:TimeTrix,代码行数:12,代码来源:Alarm.java

示例9: onCreate

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // add flag to current window
    Window window = this.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

    // init KeyguardManager

    KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);

    if (keyguardManager.inKeyguardRestrictedInputMode()) {
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(getLocalClassName());
        keyguardLock.disableKeyguard();
    }

    // wake up screen light
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "");
    wakeLock.acquire();

    // finish current activity
    finish();
}
 
开发者ID:macacajs,项目名称:unlock-apk,代码行数:29,代码来源:MainActivity.java

示例10: ConnectionsManager

import android.os.PowerManager; //导入方法依赖的package包/类
public ConnectionsManager() {
    try {
        PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
        wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
        wakeLock.setReferenceCounted(false);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:10,代码来源:ConnectionsManager.java

示例11: MmsRadio

import android.os.PowerManager; //导入方法依赖的package包/类
private MmsRadio(Context context) {
  PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  this.context             = context;
  this.connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  this.wakeLock            = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MMS Connection");
  this.wakeLock.setReferenceCounted(true);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:8,代码来源:MmsRadio.java

示例12: onCreate

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fetchLEDData();
    PowerManager pm = (PowerManager)getSystemService(
            Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
            "led");
    mWakeLock.acquire();

    final View decorView = getWindow().getDecorView();
    final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int i) {
            if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        decorView.setSystemUiVisibility(uiOptions);
                    }
                },1000);

            } else {
            }
        }
    });
}
 
开发者ID:ZhangQinglian,项目名称:LEDView,代码行数:32,代码来源:LEDActivity.java

示例13: onCreate

import android.os.PowerManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    this.context = this;

    // configuracao para que o device nao pare de rodar os processos de CPU ao ficar em modo sleep
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_NAME);
    wakeLock.acquire();

}
 
开发者ID:gabriel-silva,项目名称:MapaDeIgarassu,代码行数:12,代码来源:NavigationModeService.java

示例14: openWakeLock

import android.os.PowerManager; //导入方法依赖的package包/类
/**
 * 打开休眠锁只能保持手机不休眠
 * @param context
 */
@Deprecated
public static void openWakeLock(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Service.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Lock");
    //是否需计算锁的数量
    wakeLock.setReferenceCounted(false);
    //请求常亮,onResume()
    wakeLock.acquire();
}
 
开发者ID:finddreams,项目名称:ScreenLongLight,代码行数:14,代码来源:LongLightUtils.java

示例15: acquireWakeLock

import android.os.PowerManager; //导入方法依赖的package包/类
void acquireWakeLock() {
    if ((wl != null) && wl.isHeld()) return;
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    this.wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getString(R.string.app_name));
    try {
        wl.acquire();
        Timber.d("WakeLock acquired");
    } catch (SecurityException ex) {
        Timber.w("WakeLock NOT acquired: %s", ex.getLocalizedMessage());
        wl = null;
    }
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:13,代码来源:WalletActivity.java


注:本文中的android.os.PowerManager.newWakeLock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。