當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。