本文整理匯總了Java中android.os.PowerManager.WakeLock.setReferenceCounted方法的典型用法代碼示例。如果您正苦於以下問題:Java WakeLock.setReferenceCounted方法的具體用法?Java WakeLock.setReferenceCounted怎麽用?Java WakeLock.setReferenceCounted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.PowerManager.WakeLock
的用法示例。
在下文中一共展示了WakeLock.setReferenceCounted方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startWakefulService
import android.os.PowerManager.WakeLock; //導入方法依賴的package包/類
public static ComponentName startWakefulService(Context context, Intent intent) {
ComponentName comp;
synchronized (mActiveWakeLocks) {
int id = mNextId;
mNextId++;
if (mNextId <= 0) {
mNextId = 1;
}
intent.putExtra(EXTRA_WAKE_LOCK_ID, id);
comp = context.startService(intent);
if (comp == null) {
comp = null;
} else {
WakeLock wl = ((PowerManager) context.getSystemService("power")).newWakeLock(1, "wake:" + comp.flattenToShortString());
wl.setReferenceCounted(false);
wl.acquire(60000);
mActiveWakeLocks.put(id, wl);
}
}
return comp;
}
示例2: acquireWakeLock
import android.os.PowerManager.WakeLock; //導入方法依賴的package包/類
public static WakeLock acquireWakeLock(Context context,String tag)
{
//Setup a WakeLock
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag);
wakeLock.setReferenceCounted(true);
//acquire the lock
if(!wakeLock.isHeld())
{
wakeLock.acquire();
}
return wakeLock;
}
示例3: createWakeLock
import android.os.PowerManager.WakeLock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private WakeLock createWakeLock(KeepScreenOnMode keepScreenOnMode) {
WakeLock newWakeLock = null;
if (keepScreenOnMode == KeepScreenOnMode.FullBrightness) {
newWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, SERVICE_FULL_NAME + ".BrightWakeLock_" + System.currentTimeMillis());
newWakeLock.setReferenceCounted(false);
} else if (keepScreenOnMode == KeepScreenOnMode.Dimmed) {
newWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, SERVICE_FULL_NAME + ".DimWakeLock_" + System.currentTimeMillis());
newWakeLock.setReferenceCounted(false);
}
return newWakeLock;
}
示例4: showSelector
import android.os.PowerManager.WakeLock; //導入方法依賴的package包/類
/**
* Shows the selector dialog that allows the user to decide which music
* player should receiver the media button press intent.
*
* @param context
* The context.
* @param intent
* The intent to forward.
* @param keyEvent
* The key event
*/
private void showSelector(Context context, Intent intent, KeyEvent keyEvent) {
KeyguardManager manager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
boolean locked = manager.inKeyguardRestrictedInputMode();
Intent showForwardView = new Intent(Constants.INTENT_ACTION_VIEW_MEDIA_BUTTON_LIST);
showForwardView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
showForwardView.putExtras(intent);
showForwardView.setClassName(context,
locked ? ReceiverSelectorLocked.class.getName() : ReceiverSelector.class.getName());
/* COMMENTED OUT FOR MARKET RELEASE Log.i(TAG, "Media Button Receiver: starting selector activity for keyevent: " + keyEvent); */
if (locked) {
// XXX See if this actually makes a difference, might
// not be needed if we move more things to onCreate?
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
// acquire temp wake lock
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG);
wakeLock.setReferenceCounted(false);
// Our app better display within 3 seconds or we have
// bigger issues.
wakeLock.acquire(3000);
}
context.startActivity(showForwardView);
}