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


Java WifiLock類代碼示例

本文整理匯總了Java中android.net.wifi.WifiManager.WifiLock的典型用法代碼示例。如果您正苦於以下問題:Java WifiLock類的具體用法?Java WifiLock怎麽用?Java WifiLock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WifiLock類屬於android.net.wifi.WifiManager包,在下文中一共展示了WifiLock類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setwifilock

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
public void setwifilock() {
    WifiLock wifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "mylock");
    if (wifiLock.isHeld()){
        wifiLock.release();
    }
    else {
        wifiLock.acquire();
    }
}
 
開發者ID:leonmelein,項目名稱:Stdy__Android,代碼行數:10,代碼來源:MusicActivity.java

示例2: doInBackground

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {
	PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
	WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
	
	WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sync_all_cpu");		
	wl.acquire();
	
	WifiLock wfl = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "sync_all_wifi");
	wfl.acquire();
	
	Message[] msgs = service.getAllMessagesArray();
	d.setMax(msgs.length);
	d.setProgress(0);
	
	for (Message m : msgs) {
		service.storeSingleMessageOnDatabase(m);
		try {
			publishProgress(m.getFrom()[0].toString() + ": " + m.getSubject());
		} catch (MessagingException e) {
			Log.e("ERROR", e.getMessage());
		}
	}
	
	wl.release();
	wfl.release();
	
	return null;
}
 
開發者ID:ruvolof,項目名稱:battleclient-android,代碼行數:30,代碼來源:ShowEmails.java

示例3: getWifiLock

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
@Override
public WifiLock getWifiLock() {
	return super.getWifiLock();
}
 
開發者ID:joschi70,項目名稱:AndroidPirateBox,代碼行數:5,代碼來源:PirateBoxService.java

示例4: execute

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
@Override
public void execute(Context service) 
{
       delegate.setRestartingDroneState(IndicatorState.ACTIVE, 0, "");
	
	WifiManager wifi = (WifiManager) context.getContext().getSystemService(Context.WIFI_SERVICE);
	WifiInfo wifiInfo = wifi.getConnectionInfo();

	ssid = wifiInfo.getSSID();
	context.setDroneNetworkSSID(ssid);
	droneRestarted = false;
	
	Log.d(getCommandName(), "Current connection ssid: " + ssid);
	
	// We need this in order to prevent disconnection due to device inactivity
	WifiLock lock = wifi.createWifiLock("DRONE_RESTART_LOCK");
	lock.acquire();
	
	if (context.getDroneFirmwareVersion().startsWith("2.")) {
		if (!TelnetUtils.executeRemotely(DroneConfig.getHost(), DroneConfig.TELNET_PORT, "reboot\n")) {
	        delegate.setRestartingDroneState(IndicatorState.ACTIVE, 0, context.getContext().getString(R.string.update_file_sent_successfully_please_restart_drone));
		}
	} else {
        delegate.setRestartingDroneState(IndicatorState.ACTIVE, 0, context.getContext().getString(R.string.update_file_sent_successfully_please_restart_drone));
	}
	
	while (!context.isShuttingDown()) {
	
		if (!droneRestarted) {	
			if (FTPUtils.downloadFile(service, DroneConfig.getHost(), DroneConfig.getFtpPort(), "version.txt") == null) {
				droneRestarted = true;
				Log.d(getCommandName(), "Wifi signal lost. Marking as restarted");
				onSuccess();
				break;
			} else {
				Log.d(getCommandName(), "Wifi still enabled");
			}
		} 

		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
			break;
		}

		Log.d(getCommandName(), "Checking connection...");
	}
	
	lock.release();
}
 
開發者ID:fblandroidhackathon,項目名稱:persontracker,代碼行數:53,代碼來源:UpdaterRestartDroneCommand.java

示例5: getNewWifiLock

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
public WifiLock getNewWifiLock(String lock_postfix) {
	return mManager.createWifiLock(WifiManager.WIFI_MODE_FULL, WIFI_LOCK_TAG + lock_postfix);
}
 
開發者ID:r00li,項目名稱:RHome,代碼行數:4,代碼來源:WifiHelper.java

示例6: createWifiWakeLock

import android.net.wifi.WifiManager.WifiLock; //導入依賴的package包/類
private WifiLock createWifiWakeLock()
{
	return ((WifiManager) Util.getSystemService(this, Context.WIFI_SERVICE))
			.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "SimlarWifiLock");
}
 
開發者ID:simlar,項目名稱:simlar-android,代碼行數:6,代碼來源:SimlarService.java


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