Java WakeLock.setReferenceCounted方法代码示例

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


Java WakeLock.setReferenceCounted方法代码示例

在下文中一共展示了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

本文标签属性:

示例:示例英语

代码:代码编程

java:javascript18岁

上一篇:Python ipywidgets.FloatSlider方法代码示例
下一篇:C++ osd_oti_get函数代码示例

为您推荐