當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。