本文整理匯總了Java中android.net.wifi.WifiManager.WIFI_STATE_DISABLED屬性的典型用法代碼示例。如果您正苦於以下問題:Java WifiManager.WIFI_STATE_DISABLED屬性的具體用法?Java WifiManager.WIFI_STATE_DISABLED怎麽用?Java WifiManager.WIFI_STATE_DISABLED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.net.wifi.WifiManager
的用法示例。
在下文中一共展示了WifiManager.WIFI_STATE_DISABLED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceive
@Override
public void onReceive(Context context, @NonNull Intent intent)
{
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
switch (wifiState)
{
case WifiManager.WIFI_STATE_ENABLED:
wifiStateCallback.onWifiEnabled();
break;
case WifiManager.WIFI_STATE_ENABLING:
break;
case WifiManager.WIFI_STATE_DISABLING:
break;
case WifiManager.WIFI_STATE_DISABLED:
break;
}
}
示例2: onHandleIntent
@Override
protected void onHandleIntent(Intent intent) {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST);
if (intent == null) {
Utils.debugLog(TAG, "received null Intent, ignoring");
return;
}
Utils.debugLog(TAG, "WiFi change service started, clearing info about wifi state until we have figured it out again.");
NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
int wifiState = wifiManager.getWifiState();
if (ni == null || ni.isConnected()) {
Utils.debugLog(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState));
if (wifiState == WifiManager.WIFI_STATE_ENABLED
|| wifiState == WifiManager.WIFI_STATE_DISABLING // might be switching to hotspot
|| wifiState == WifiManager.WIFI_STATE_DISABLED // might be hotspot
|| wifiState == WifiManager.WIFI_STATE_UNKNOWN) { // might be hotspot
if (wifiInfoThread != null) {
wifiInfoThread.interrupt();
}
wifiInfoThread = new WifiInfoThread();
wifiInfoThread.start();
}
}
}
示例3: handleMessage
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case WifiManager.WIFI_STATE_ENABLED:
LogUtils.d("savor:網絡變為可用");
// 為了解決多次重複發送請求利用延時發送方式
getSmallPlatformUrl();
isWifi = true;
break;
case WifiManager.WIFI_STATE_DISABLED:
wifi.setVisibility(View.INVISIBLE);
isWifi = false;
break;
}
}
示例4: wifiDisable
@Rpc(description = "Turns off Wi-Fi with a 30s timeout.")
public void wifiDisable() throws InterruptedException, WifiManagerSnippetException {
if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED) {
return;
}
// If Wi-Fi is trying to turn on, wait for that to complete before continuing.
if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING) {
if (!Utils.waitUntil(
() -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED,
TIMEOUT_TOGGLE_STATE)) {
Log.e(String.format("Wi-Fi failed to stabilize after %ss.", TIMEOUT_TOGGLE_STATE));
}
}
if (!mWifiManager.setWifiEnabled(false)) {
throw new WifiManagerSnippetException("Failed to initiate disabling Wi-Fi.");
}
if (!Utils.waitUntil(
() -> mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED,
TIMEOUT_TOGGLE_STATE)) {
throw new WifiManagerSnippetException(
String.format(
"Failed to disable Wi-Fi after %ss, timeout!", TIMEOUT_TOGGLE_STATE));
}
}
示例5: onReceive
@Override
public void onReceive(Context c, Intent intent) {
Bundle bundle = intent.getExtras();
int statusInt = bundle.getInt("wifi_state");
switch (statusInt) {
case WifiManager.WIFI_STATE_UNKNOWN:
break;
case WifiManager.WIFI_STATE_ENABLING:
break;
case WifiManager.WIFI_STATE_ENABLED:
LogUtil.e(TAG, "wifi enable");
startThread();
break;
case WifiManager.WIFI_STATE_DISABLING:
break;
case WifiManager.WIFI_STATE_DISABLED:
LogUtil.e(TAG, "wifi disabled");
break;
default:
break;
}
}
示例6: printWifiState
private String printWifiState(int wifiState) {
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLED:
return "WIFI_STATE_DISABLED";
case WifiManager.WIFI_STATE_DISABLING:
return "WIFI_STATE_DISABLING";
case WifiManager.WIFI_STATE_ENABLING:
return "WIFI_STATE_ENABLING";
case WifiManager.WIFI_STATE_ENABLED:
return "WIFI_STATE_ENABLED";
case WifiManager.WIFI_STATE_UNKNOWN:
return "WIFI_STATE_UNKNOWN";
}
return null;
}
示例7: handleMessage
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SENSOR_SHAKE:
exitGameDelayed();
playHammerAnimation();
break;
case EXIT_PRO:
finish();
break;
case WifiManager.WIFI_STATE_ENABLED:
break;
case WifiManager.WIFI_STATE_DISABLED:
mNetWorkSettingsDialog = new CommonDialog(GameActivity.this,"請連接包間wifi","連接後可查看當前酒樓是否有優惠活動"
, new CommonDialog.OnConfirmListener() {
@Override
public void onConfirm() {
Intent intent = new Intent();
intent.setAction("android.net.wifi.PICK_WIFI_NETWORK");
startActivity(intent);
finish();
}
}, new CommonDialog.OnCancelListener() {
@Override
public void onCancel() {
finish();
}
},"去連接");
mNetWorkSettingsDialog.show();
break;
}
}
示例8: onReceive
@Override
public void onReceive(Context context, Intent intent) {
//wifi更換時判斷目標是不是學校wifi,不是的話就停掉
if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info.getState().equals(NetworkInfo.State.CONNECTED)) { //連上wifi
WifiUtils wifiUtils = new WifiUtils(context);
boolean isSchoolWifi = WifiUtils.currentIsSchoolWifi(wifiUtils);
if(!isSchoolWifi){
performMsgCall("wifi切換,已退出登陸");
cancelNotification();
stopSelf(); //停止service
return;
}
}
}
//wifi關閉就直接停掉
if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
if (wifiState == WifiManager.WIFI_STATE_DISABLED) {
performMsgCall("wifi已關閉,自動退出登陸");
cancelNotification();
stopSelf(); //停止service
}
// if (wifistate == WifiManager.WIFI_STATE_ENABLED) WIFI開啟
}
}
示例9: updateWiFiState
private void updateWiFiState(int wifiState) {
int state;
int actionState;
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLING:
state = R.string.txt_status_turning_off;
actionState = STATE_INPROCESS;
break;
case WifiManager.WIFI_STATE_DISABLED:
state = R.string.txt_status_turned_off;
actionState = STATE_DONE;
break;
case WifiManager.WIFI_STATE_ENABLING:
state = R.string.txt_status_turning_on;
actionState = STATE_INPROCESS;
break;
case WifiManager.WIFI_STATE_ENABLED:
state = R.string.txt_status_turned_on;
actionState = STATE_DONE;
break;
default:
state = R.string.txt_status_unknown;
actionState = STATE_DONE;
break;
}
String stateText = mActivity.getString(state);
setActionState(actionState);
// update description
Setting setting = mSetting;
setting.descr = stateText;
setting.checked = wifiState == WifiManager.WIFI_STATE_ENABLED || wifiState == WifiManager.WIFI_STATE_DISABLING;
setting.updateView();
}
示例10: onReceive
@Override
public void onReceive(Context context, Intent intent) {
//wifi更換時判斷目標是不是學校wifi,不是的話就停掉
if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info.getState().equals(NetworkInfo.State.CONNECTED)) { //連上wifi
WifiUtils wifiUtils = new WifiUtils(context);
boolean isSchoolWifi = DrcomActivity.currentIsSchoolWifi(wifiUtils);
if(!isSchoolWifi){
performMsgCall("wifi切換,已退出登陸");
cancelNotification();
stopSelf(); //停止service
return;
}
}
}
//wifi關閉就直接停掉
if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
if (wifiState == WifiManager.WIFI_STATE_DISABLED) {
performMsgCall("wifi已關閉,自動退出登陸");
cancelNotification();
stopSelf(); //停止service
}
// if (wifistate == WifiManager.WIFI_STATE_ENABLED) WIFI開啟
}
}
示例11: onReceive
@Override
public void onReceive(Context context, Intent intent) {
// 這個監聽wifi的打開與關閉,與wifi的連接無關
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
Log.e(TAG, "wifiState" + wifiState);
switch (wifiState) {
case WifiManager.WIFI_STATE_DISABLED:
Log.d(TAG, "onReceive: WIFI_STATE_DISABLED");
break;
case WifiManager.WIFI_STATE_DISABLING:
break;
case WifiManager.WIFI_STATE_ENABLING:
break;
case WifiManager.WIFI_STATE_ENABLED:
Log.d(TAG, "onReceive: WIFI_STATE_ENABLED");
break;
case WifiManager.WIFI_STATE_UNKNOWN:
break;
default:
break;
}
}
// 這個監聽wifi的連接狀態即是否連上了一個有效無線路由,當上邊廣播的狀態是WifiManager
// .WIFI_STATE_DISABLING,和WIFI_STATE_DISABLED的時候,根本不會接到這個廣播。
// 在上邊廣播接到廣播是WifiManager.WIFI_STATE_ENABLED狀態的同時也會接到這個廣播,
// 當然剛打開wifi肯定還沒有連接到有效的無線
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (null != parcelableExtra) {
NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
NetworkInfo.State state = networkInfo.getState();
boolean isConnected = state == State.CONNECTED;// 當然,這邊可以更精確的確定狀態
Log.e(TAG, "isConnected" + isConnected);
if (isConnected) {
} else {
}
}
}
// 這個監聽網絡連接的設置,包括wifi和移動數據的打開和關閉。.
// 最好用的還是這個監聽。wifi如果打開,關閉,以及連接上可用的連接都會接到監聽。見log
// 這個廣播的最大弊端是比上邊兩個廣播的反應要慢,如果隻是要監聽wifi,我覺得還是用上邊兩個配合比較合適
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
Log.i(TAG, "CONNECTIVITY_ACTION");
NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
if (activeNetwork != null) { // connected to the internet
if (activeNetwork.isConnected()) {
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
// connected to wifi
Log.e(TAG, "當前WiFi連接可用 ");
} else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
// connected to the mobile provider's data plan
Log.e(TAG, "當前移動網絡連接可用 ");
}
} else {
Log.e(TAG, "當前沒有網絡連接,請確保你已經打開網絡 ");
}
Log.e(TAG, "info.getTypeName()" + activeNetwork.getTypeName());
Log.e(TAG, "getSubtypeName()" + activeNetwork.getSubtypeName());
Log.e(TAG, "getState()" + activeNetwork.getState());
Log.e(TAG, "getDetailedState()"+ activeNetwork.getDetailedState().name());
Log.e(TAG, "getDetailedState()" + activeNetwork.getExtraInfo());
Log.e(TAG, "getType()" + activeNetwork.getType());
} else { // not connected to the internet
Log.e(TAG, "當前沒有網絡連接,請確保你已經打開網絡 ");
}
}
}
示例12: wifiStateChangedAction
/**
*
* @param context
* @param intent
* @param action
*/
public static void wifiStateChangedAction(Context context, Intent intent, String action)
{
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action))
{
// 在此監聽wifi有無
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
switch (wifiState)
{
case WifiManager.WIFI_STATE_DISABLED:
{
Toast.makeText(context, "WIFI_STATE_DISABLED", Toast.LENGTH_LONG).show();
break;
}
case WifiManager.WIFI_STATE_DISABLING:
{
Toast.makeText(context, "WIFI_STATE_DISABLING", Toast.LENGTH_LONG).show();
break;
}
case WifiManager.WIFI_STATE_ENABLED:
{
Toast.makeText(context, "WIFI_STATE_ENABLED", Toast.LENGTH_LONG).show();
break;
}
case WifiManager.WIFI_STATE_ENABLING:
{
Toast.makeText(context, "WIFI_STATE_ENABLING", Toast.LENGTH_LONG).show();
break;
}
case WifiManager.WIFI_STATE_UNKNOWN:
{
Toast.makeText(context, "WIFI_STATE_UNKNOWN", Toast.LENGTH_LONG).show();
break;
}
}
}
}
示例13: handleMessage
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case CLOSE_SSDP_SERVICE:
LogUtils.d("savor:ssdp 搜索10秒,關閉ssdp服務");
Intent ssdpIntent = new Intent(mContext, SSDPService.class);
mContext.stopService(ssdpIntent);
break;
case SAVE_BOX_INFO:
Object obj = msg.obj;
if(obj instanceof TvBoxInfo) {
TvBoxInfo tvBoxInfo = (TvBoxInfo) obj;
mSession.setTvBoxUrl(tvBoxInfo);
mBindTvView.initBindcodeResult();
}
break;
case SCAN_QR:
LogUtils.d("二維碼結果:" + msg.obj);
if (TextUtils.isEmpty(msg.obj + "")) {
mViewCallBack.showToast("無效的數字");
return;
}
// 綁定tv
mSession.setTVBoxUrl(msg.obj + "");
mBindTvView.initBindcodeResult();
break;
case START_LINKTV:
if(mBindTvView!=null) {
mBindTvView.closeQrcodeDialog();
String topNameActivity = getTopActivityName(mContext);
if(!topNameActivity.equals(LinkTvActivity.class.getClass().getName())){
mBindTvView.startLinkTv();
}
}
case CLOSE_DIALOG:
if(mBindTvView!=null)
mBindTvView.closeQrcodeDialog();
break;
case CALL_QRCODE:
break;
case CALL_CODE_ERRO:
mViewCallBack.showToast("呼出二維碼網絡超時");
break;
case WifiManager.WIFI_STATE_ENABLED:
LogUtils.d("savor:網絡變為可用");
// 為了解決多次重複發送請求利用延時發送方式
getSmallPlatformUrl(true);
break;
case WifiManager.WIFI_STATE_DISABLED:
LogUtils.d("savor:hotel 網絡不可用重置酒店id為0");
mSession.resetPlatform();
mSession.setHotelid(0);
mSenseView.hideProjection();
stopProAndLink();
break;
case CHECK_PLATFORM:
getSmallPlatformUrl(false);
break;
case GET_SMALL_FLATFORM:
getSmallPlatformUrl(false);
break;
case REMOVE_QRCODE:
mSession.setQrcode(null);
break;
case REMOVE_BOX_INFO:
mSession.setTvBoxUrl(null);
break;
}
}
示例14: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
//獲取當前的wifi狀態int類型數據
int mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
switch (mWifiState) {
case WifiManager.WIFI_STATE_ENABLED:
//已打開
getWifiList();
break;
case WifiManager.WIFI_STATE_ENABLING:
//打開中
break;
case WifiManager.WIFI_STATE_DISABLED:
//已關閉
break;
case WifiManager.WIFI_STATE_DISABLING:
//關閉中
break;
case WifiManager.WIFI_STATE_UNKNOWN:
//未知
break;
}
} else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
int linkWifiResult = intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, 123);
Log.d("XLight", "Get WiFi Result:" + linkWifiResult);
if (linkWifiResult == WifiManager.ERROR_AUTHENTICATING) {
ToastUtil.showToast(getApplicationContext(), "密碼錯誤");
}
} else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {//wifi連接上與否
Log.d("XLight", "網絡狀態改變");
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
Log.d("XLight", "wifi網絡連接斷開");
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
android.net.wifi.WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//獲取當前wifi名稱
Log.d("XLight", "連接到網絡 " + wifiInfo.getSSID());
}
}
}
示例15: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
//獲取當前的wifi狀態int類型數據
int mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
switch (mWifiState) {
case WifiManager.WIFI_STATE_ENABLED:
//已打開
getWifiList();
break;
case WifiManager.WIFI_STATE_ENABLING:
//打開中
break;
case WifiManager.WIFI_STATE_DISABLED:
//已關閉
break;
case WifiManager.WIFI_STATE_DISABLING:
//關閉中
break;
case WifiManager.WIFI_STATE_UNKNOWN:
//未知
break;
}
} else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {//wifi連接上與否
Log.d("XLight", "網絡狀態改變");
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
Log.d("XLight", "wifi網絡連接斷開");
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
android.net.wifi.WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String ssid = wifiInfo.getSSID();
//獲取當前wifi名稱
Log.d("XLight", "連接到網絡 " + ssid + ssid.contains("Photon-") + ssid.length());
if (ssid.contains("Photon-") && ssid.length() >= 11) {
//連接成功,跳到下一個頁麵
Intent intent1 = new Intent(getApplicationContext(), BindDeviceWiFiActivity.class);
intent1.putExtra("type", type);
startActivity(intent1);
finish();
}
}
}
}