当前位置: 首页>>代码示例>>Java>>正文


Java WakeLock.isHeld方法代码示例

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


在下文中一共展示了WakeLock.isHeld方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: keepScreenOn

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
/**
 * 保持屏幕常亮
 *
 * @param activity you know
 */
public static void keepScreenOn(Activity activity) {
    WakeLock wakeLock = mWakeLockArray.get(activity);
    if (wakeLock == null) {
        PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK,
                activity.getClass().getName());
    }

    if (!wakeLock.isHeld()) {
        wakeLock.acquire();
    }

    mWakeLockArray.put(activity, wakeLock);

    cancelLockScreen(activity);

    Log.i(TAG, "开启屏幕常亮");
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:24,代码来源:ScreenLockUtil.java

示例2: acquire

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static synchronized void acquire(Context context) {
	WakeLock wakeLock = getLock(context);
	if (!wakeLock.isHeld()) {
		wakeLock.acquire();
		//Log.d("alogcat", "wake lock acquired");
	}
}
 
开发者ID:pedja1,项目名称:Kernel-Tuner,代码行数:8,代码来源:Lock.java

示例3: 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, "取消屏幕常亮");
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:16,代码来源:ScreenLockUtil.java

示例4: _acquireWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
private boolean _acquireWakeLock(WakeLock lock, long timeout) {
    synchronized (lock) {
        if (!lock.isHeld()) {
            if (timeout > 0) {
                lock.acquire(timeout);
            } else {
                lock.acquire();
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:zxcpoiu,项目名称:react-native-incall-manager,代码行数:14,代码来源:InCallWakeLockUtils.java

示例5: _releaseWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
private boolean _releaseWakeLock(WakeLock lock) {
    synchronized (lock) {
        if (lock.isHeld()) {
            lock.release();
            return true;
        }
    }
    return false;
}
 
开发者ID:zxcpoiu,项目名称:react-native-incall-manager,代码行数:10,代码来源:InCallWakeLockUtils.java

示例6: 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

示例7: releaseWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static void releaseWakeLock(WakeLock wakeLock)
{
	if(wakeLock != null)
	{
		if(wakeLock.isHeld())
		{
			wakeLock.release();
		}
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:11,代码来源:GeneralTools.java

示例8: acquireWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static void acquireWakeLock(final String TAG, int levelAndFlags, Context context){
    WakeLock wakeLock = wakeLocks.get(TAG);
    if(wakeLock == null){
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(levelAndFlags, TAG);
        wakeLocks.put(TAG, wakeLock);
        wakeLock.acquire();
    } else if(!wakeLock.isHeld()){
        wakeLock.acquire();
    } else {
        Log.v(LOG_TAG, "Wakelock already acquired:" + TAG);
    }
}
 
开发者ID:aravindsagar,项目名称:SmartLockScreen,代码行数:14,代码来源:WakeLockHelper.java

示例9: releaseWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
public static void releaseWakeLock(final String TAG){
    WakeLock wakeLock = wakeLocks.get(TAG);
    if(!Utility.checkForNullAndWarn(wakeLock, LOG_TAG)){
        if(wakeLock.isHeld()) wakeLock.release();
        //wakeLocks.remove(TAG); Not sure about this; might be good to keep the wakeLock object.
    }
}
 
开发者ID:aravindsagar,项目名称:SmartLockScreen,代码行数:8,代码来源:WakeLockHelper.java

示例10: setWakeLock

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
private synchronized final void setWakeLock(boolean enableLock) {
    WakeLock wl = wakeLock;
    if (wl != null) {
        if (wl.isHeld())
            wl.release();
        if (enableLock)
            wl.acquire();
    }
}
 
开发者ID:spdd,项目名称:chessonline,代码行数:10,代码来源:DroidFish.java

示例11: doInBackground

import android.os.PowerManager.WakeLock; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(String... strParams)
{
    Boolean result = Boolean.FALSE;

    // get a wakelock to hold for the duration of the background work. downloading
    // may be slow. extraction usually isn't too slow but also takes a bit of time. limit the wakelock's time!
    PowerManager powerManager = (PowerManager)m_ctx.getSystemService(Context.POWER_SERVICE);
    WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SettingsDownloaderWakeLock");
    wakeLock.acquire(FOUR_MINUTES);

    // download the file
    String filename = downloadFile(strParams[0]);
    if (filename != null)
    {
        File fSettingsZip = new File(filename);
        if (fSettingsZip.exists() && !isCancelled())
        {
            try
            {
                m_logWriter.write("Successfully downloaded to: "+filename+"\n");

                // extract to wanted directory
                String destDir = strParams[1];
                boolean bSuccess = extractSettingsZip(fSettingsZip, destDir);
                result = (bSuccess ? Boolean.TRUE : Boolean.FALSE);

                // delete settings zip
                if (fSettingsZip.exists()) {
                    fSettingsZip.delete();
                }
            }
            catch(Exception e)
            {
                Log.e("SettingsDownloader", "Error: "+e.toString());
            }
        }
    }

    // if our max time hasn't passed but work is done or an error occurred we bail out and release
    if (wakeLock.isHeld())
    {
        wakeLock.release();
    }

    return result;
}
 
开发者ID:voguemaster,项目名称:SettingsDeployer,代码行数:48,代码来源:SettingsDownloader.java


注:本文中的android.os.PowerManager.WakeLock.isHeld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。