本文整理汇总了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();
}
}
示例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;
}
示例3: getWifiLock
import android.net.wifi.WifiManager.WifiLock; //导入依赖的package包/类
@Override
public WifiLock getWifiLock() {
return super.getWifiLock();
}
示例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();
}
示例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);
}
示例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");
}