当前位置: 首页>>代码示例>>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;未经允许,请勿转载。