當前位置: 首頁>>代碼示例>>Java>>正文


Java WakeLock.setReferenceCounted方法代碼示例

本文整理匯總了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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:WakefulBroadcastReceiver.java

示例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;
}
 
開發者ID:ZalemSoftware,項目名稱:OpenMobster,代碼行數:16,代碼來源:GeneralTools.java

示例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;
}
 
開發者ID:zamojski,項目名稱:TowerCollector,代碼行數:13,代碼來源:CollectorService.java

示例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);
}
 
開發者ID:harleensahni,項目名稱:media-button-router,代碼行數:40,代碼來源:MediaButtonReceiver.java


注:本文中的android.os.PowerManager.WakeLock.setReferenceCounted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。