本文整理汇总了Java中android.os.PowerManager.WakeLock.release方法的典型用法代码示例。如果您正苦于以下问题:Java WakeLock.release方法的具体用法?Java WakeLock.release怎么用?Java WakeLock.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.PowerManager.WakeLock
的用法示例。
在下文中一共展示了WakeLock.release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wakeUpScreen
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static void wakeUpScreen (Context ctx) {
PowerManager pm = (PowerManager)ctx.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = true;
// greater or equal to api level 20
if (Build.VERSION.SDK_INT > AlarmNotificationUtil.FAKE_KITKAT_WATCH) {
isScreenOn = pm.isInteractive();
Log.v("cpeng", "alarm screen is interactive");
}
else if (Build.VERSION.SDK_INT <= AlarmNotificationUtil.FAKE_KITKAT_WATCH) {
isScreenOn = pm.isScreenOn();
Log.v("cpeng", "alarm screen is on");
}
else {
Log.v("cpeng", "alarm screen OFF");
}
if(isScreenOn==false)
{
WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,"ALock");
wl.acquire(10000);
wl.release();
// WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"ACPULock");
// wl_cpu.acquire(10000);
}
}
示例2: run
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Migration");
try {
wakeLock.acquire();
setState(new ImportState(ImportState.STATE_MIGRATING_BEGIN, null));
SmsMigrator.migrateDatabase(ApplicationMigrationService.this,
masterSecret,
ApplicationMigrationService.this);
setState(new ImportState(ImportState.STATE_MIGRATING_COMPLETE, null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
示例3: completeWakefulIntent
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static boolean completeWakefulIntent(Intent intent) {
int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID, 0);
if (id == 0) {
return false;
}
synchronized (mActiveWakeLocks) {
WakeLock wl = (WakeLock) mActiveWakeLocks.get(id);
if (wl != null) {
wl.release();
mActiveWakeLocks.remove(id);
return true;
}
Log.w("WakefulBroadcastReceiver", "No active wake lock id #" + id);
return true;
}
}
示例4: onReceive
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
/**
* Sets alarm on ACTION_BOOT_COMPLETED. Resets alarm on
* TIME_SET, TIMEZONE_CHANGED
*/
@Override
public void onReceive(final Context context, Intent intent) {
final String action = intent.getAction();
Log.d("AlarmInitReceiver" + action);
if (App.fejlsøgning) App.langToast("AlarmInitReceiver onReceive(" + intent);
//final PendingResult result = goAsync();
final WakeLock wl = AlarmAlertWakeLock.createPartialWakeLock(context);
if (wl!=null) wl.acquire(); // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/3315048120
Alarms.setNextAlert(context);
// result.finish();
Log.d("AlarmInitReceiver finished");
if (wl!=null) wl.release(); // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/3315048120
}
示例5: onReceive
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
@SuppressLint("Wakelock")
public void onReceive(Context context, Intent intent) {
traceDebug(TAG, "Internal network status receive.");
// we protect against the phone switching off
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the CPU running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT");
wl.acquire();
traceDebug(TAG,"Reconnect for Network recovery.");
if (isOnline()) {
traceDebug(TAG,"Online,reconnect.");
// we have an internet connection - have another try at
// connecting
reconnect();
} else {
notifyClientsOffline();
}
wl.release();
}
示例6: processLocation
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
private WeatherLocation processLocation(Location location) {
if (location != null) {
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MobileWeatherProcessLocation");
try {
wakeLock.acquire();
WeatherLocation loc = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent()) {
loc = reverseGeocode(location);
}
else {
loc = new WeatherLocation();
GPSLocation gpsLoc = new GPSLocation();
gpsLoc.latitude = String.valueOf(location.getLatitude());
gpsLoc.longitude = String.valueOf(location.getLongitude());
loc.gpsLocation = gpsLoc;
}
return loc;
} finally {
wakeLock.release();
}
}
return null;
}
开发者ID:smartdevicelink,项目名称:sdl_mobileweather_tutorial_android,代码行数:27,代码来源:WeatherLocationServices.java
示例7: riseAndShine
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void riseAndShine(Activity activity) {
KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(activity.getLocalClassName());
keyguardLock.disableKeyguard();
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
WakeLock lock = powerManager.newWakeLock(
PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
"wakeup!");
lock.acquire();
lock.release();
}
示例8: onReceive
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
traceDebug(TAG, "Internal network status receive.");
// we protect against the phone switching off
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the CPU running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT");
wl.acquire();
if (isOnline()) {
// we have an internet connection - have another try at
// connecting
reconnect();
} else {
notifyClientsOffline();
}
wl.release();
}
示例9: onReceive
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
public void onReceive(Context ctx, Intent intent)
{
// we protect against the phone switching off while we're doing this
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the CPU running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT");
wl.acquire();
if (isOnline())
{
// we have an internet connection - have another try at connecting
if (connectToBroker())
{
// we subscribe to a topic - registering to receive push
// notifications with a particular key
subscribeToTopic(topicName);
}
}
// we're finished - if the phone is switched off, it's okay for the CPU
// to sleep now
wl.release();
}
示例10: onReceive
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
public void onReceive(Context ctx, Intent intent) {
//Unlock device screen
PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
wl.acquire(30*1000);
mKeyGuardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock mLock = mKeyGuardManager.newKeyguardLock("com.inostudio.alar_clock");
mLock.disableKeyguard();
//Create notification
creatNotification(ctx);
//Start dialog
Intent dialog = new Intent();
dialog.setClassName("com.inostudio.alarm_clock", "com.inostudio.alarm_clock.RootActivity");
dialog.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(dialog);
//release screen
wl.release();
}
示例11: onPause
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
protected void onPause() {
// remove wake lock
WakeLock lock = mLock;
if (lock != null) lock.release();
mLock = null;
mSwitchDetector.inactivate(this);
super.onPause();
}
示例12: cancelKeepScreen
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
/**
* 取消屏幕常亮
*
* @param activity you know
*/
public static void cancelKeepScreen(Activity activity) {
WakeLock wakeLock = mWakeLockArray.get(activity);
if (wakeLock != null) {
if (wakeLock.isHeld()) {
wakeLock.release();
}
}
Log.i(TAG, "取消屏幕常亮");
}
示例13: _releaseWakeLock
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
private boolean _releaseWakeLock(WakeLock lock) {
synchronized (lock) {
if (lock.isHeld()) {
lock.release();
return true;
}
}
return false;
}
示例14: releaseWakeLock
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static void releaseWakeLock(WakeLock wakeLock)
{
if(wakeLock != null)
{
if(wakeLock.isHeld())
{
wakeLock.release();
}
}
}
示例15: onLocationChanged
import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
if (location != null) {
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MobileWeatherLocationChanged");
try {
wakeLock.acquire();
Intent intent = new Intent("com.ford.mobileweather.Location");
WeatherLocation loc = processLocation(location);
if (loc != null) {
if (mDataManager != null) {
mDataManager.setCurrentLocation(loc);
reportLocationAvail(true);
if (((System.currentTimeMillis() - mLastLocationTime) / 1000.0 > MIN_TIME_BETWEEN_LOCATION_UPDATES)) {
LocalBroadcastManager.getInstance(mApplicationContext).sendBroadcast(intent);
mLastLocationTime = System.currentTimeMillis();
}
}
} else {
Log.e(SmartDeviceLinkApplication.TAG, "onLocationChanged: loc == null");
reportLocationAvail(false);
}
} finally {
wakeLock.release();
}
} else {
Log.e(SmartDeviceLinkApplication.TAG, "onLocationChanged: location == null");
reportLocationAvail(false);
}
}
开发者ID:smartdevicelink,项目名称:sdl_mobileweather_tutorial_android,代码行数:34,代码来源:WeatherLocationServices.java