本文整理匯總了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");
}