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


Java SupplicantState.COMPLETED屬性代碼示例

本文整理匯總了Java中android.net.wifi.SupplicantState.COMPLETED屬性的典型用法代碼示例。如果您正苦於以下問題:Java SupplicantState.COMPLETED屬性的具體用法?Java SupplicantState.COMPLETED怎麽用?Java SupplicantState.COMPLETED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.net.wifi.SupplicantState的用法示例。


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

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    _logger.Debug("_wifiStateReceiver onReceive");

    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if ((SupplicantState.isValidState(state) && state == SupplicantState.COMPLETED)) {
            _logger.Debug("Successfully connected WIFI completed!");

            if (_sendDataController.GetSelectedServerIp() == null) {
                SearchForServer();
            }
        }
    } else {
        _logger.Warn(String.format("Action is %s", action));
    }
}
 
開發者ID:GuepardoApps,項目名稱:PasswordSafe-AndroidClient,代碼行數:18,代碼來源:AccountListViewController.java

示例2: updateTrust

private void updateTrust(String trustedSsid) {
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null) {
        return;
    }

    if (wifiInfo.getSSID() == null) {
        return;
    }

    if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
        if (trustedSsid.equals(wifiInfo.getSSID())) {
            GhettoTrustAgent.sendGrantTrust(this, "GhettoTrustAgent", TRUST_DURATION_30SECS,
                    false);
        }
        else {
            Log.d(TAG, "Found insecure SSID: " + trustedSsid);
            GhettoTrustAgent.sendRevokeTrust(this);
        }
    } else {
        Log.d(TAG, "Disconnected from Wifi: " + trustedSsid);
        GhettoTrustAgent.sendRevokeTrust(this);
    }
}
 
開發者ID:nelenkov,項目名稱:ghetto-unlock,代碼行數:24,代碼來源:GhettoTrustAgentSettings.java

示例3: execute

@Override
public void execute(Context service) 
{
       delegate.setInstallingState(IndicatorState.ACTIVE, 0, service.getString(R.string.if_ardrone_led_green_reset_wifi_connection));
       
       boolean connected = false;
       WifiManager mgr = (WifiManager) service.getSystemService(Context.WIFI_SERVICE);
       
       while (!connected) {
           WifiInfo info = mgr.getConnectionInfo();
           
           SupplicantState state = info.getSupplicantState();
           
           if (state == SupplicantState.COMPLETED ||
               state == SupplicantState.DORMANT) {
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                  break;
               }
               break;
           }
       }
       
       delegate.setInstallingState(IndicatorState.ACTIVE, 0, service.getString(R.string.if_ardrone_led_green_reset_wifi_connection));
}
 
開發者ID:fblandroidhackathon,項目名稱:persontracker,代碼行數:26,代碼來源:UpdaterInstallCommand.java

示例4: onReceive

@Override
public void onReceive(Context context, Intent intent) {

    final String action = intent.getAction();
    if(BuildConfig.DEBUG) Logger.debug(TAG, "onReceive:" + action);

    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION .equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if(state == SupplicantState.COMPLETED) {
            final WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
            if(wifiManager != null) {
                WifiInfo info = wifiManager.getConnectionInfo();
                if (info != null) {
                    mContext = context;
                    onWiFiConnected(info.getSSID());
                }
            }
        }
    }
}
 
開發者ID:hmrs-cr,項目名稱:android-wear-gopro-remote,代碼行數:20,代碼來源:WifiIntentReceiver.java

示例5: onReceive

@Override
public void onReceive(final Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if (!(SupplicantState.isValidState(state) && state == SupplicantState.COMPLETED)) {
            Logger.getInstance().Warning(TAG, "Not yet a valid connection!");
            return;
        }
    }

    new Handler().postDelayed(() -> {
        BroadcastController broadcastController = new BroadcastController(context);
        if (new NetworkController(context).IsHomeNetwork(SettingsController.getInstance().GetHomeSsid())) {
            if (!new AndroidSystemController(context).IsServiceRunning(MainService.class)) {
                Intent startMainServiceIntent = new Intent(context, MainService.class);
                startMainServiceIntent.putExtra(MainService.MainServiceOnStartCommandBundle, true);
                context.startService(startMainServiceIntent);
            } else {
                broadcastController.SendSimpleBroadcast(MainService.MainServiceStartDownloadAllBroadcast);
            }
            broadcastController.SendSimpleBroadcast(NetworkController.WIFIReceiverInHomeNetworkBroadcast);
        } else {
            TemperatureService.getInstance().CloseNotification();
            WirelessSocketService.getInstance().CloseNotification();
            WirelessSwitchService.getInstance().CloseNotification();
            broadcastController.SendSimpleBroadcast(NetworkController.WIFIReceiverNoHomeNetworkBroadcast);
        }
    }, 10 * 1000);
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:30,代碼來源:WIFIReceiver.java

示例6: startScan

private void startScan() {
  SupplicantState wifiState = remoController.getWifiState();
  Log.d(TAG, "startScan: " + wifiState);

  if (wifiState != SupplicantState.COMPLETED) {
    changeState(State.WIFI_ERROR);
    showWifiErrorDialog();
    return;
  } else {
    changeState(State.SCAN);
    remoController.startDiscovery();
    deviceMap = new HashMap<String, String>();
    showScanDialog();
  }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:15,代碼來源:RemoConfigFragment.java

示例7: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION .equals(action)) {
        SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
        if (SupplicantState.isValidState(state)
                && state == SupplicantState.COMPLETED) {

            mIsConnected = checkConnectedToDesiredWifi();
            if(mCallback != null){
                if(mIsConnected){
                    mCallback.onSuccess();
                }
                else{
                    mCallback.onFailed();
                }
            }

        }
        else if(SupplicantState.isValidState(state)
                && state == SupplicantState.DISCONNECTED){
            Log.d(mTAG, "Wifi STA is disconnected");
            WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
            wifiManager.reconnect();
        }
    }
}
 
開發者ID:dmtan90,項目名稱:Sense-Hub-Android-Things,代碼行數:27,代碼來源:WifiSta.java

示例8: isConnected

public static boolean isConnected(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    SupplicantState supplicantState = wifiInfo.getSupplicantState();
    if (supplicantState == SupplicantState.COMPLETED) {
        if (netInfo != null && netInfo.isConnected())
            return true;

    }
    return false;
}
 
開發者ID:crux-bphc,項目名稱:Cyber-Connect-Android,代碼行數:13,代碼來源:LoginController.java

示例9: getWifiIp

private  String getWifiIp() {
    WifiManager mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    WifiInfo mWifiInfo = mWifiManager.getConnectionInfo();
    Log.e("IP in Mask Integer", mWifiInfo.getIpAddress() + "");
    Log.e("IP Address", intToIP(mWifiInfo.getIpAddress()) + "");
    Log.e("ip-widget", "Supplicant state" + mWifiInfo.getSupplicantState());

    if(mWifiManager.isWifiEnabled() && (mWifiInfo.getSupplicantState() == SupplicantState.ASSOCIATED || mWifiInfo.getSupplicantState() == SupplicantState.COMPLETED)) {
        return mWifiInfo.getSSID() + " - " + intToIP(mWifiInfo.getIpAddress());
    }

    return "Disconnected";
}
 
開發者ID:angeldearbo,項目名稱:ip-widget,代碼行數:13,代碼來源:MyWidget.java

示例10: getSSID

/**
 * The ssid of the currently connected network.
 */
public String getSSID() {
    WifiManager wifiManager = (WifiManager) context.getSystemService (Context.WIFI_SERVICE);
    WifiInfo info = wifiManager.getConnectionInfo ();
    if (info.getSupplicantState() == SupplicantState.COMPLETED) {
        String ssid = info.getSSID();
        // https://code.google.com/p/android/issues/detail?id=43336
        if (ssid.equals("0x") || ssid.equals("<unknown ssid>")) {
            return "";
        }
        return ssid;
    }
    return "";
}
 
開發者ID:connectordb,項目名稱:connectordb-android,代碼行數:16,代碼來源:DatapointCache.java

示例11: initWifi

protected void initWifi(final Preference pref, Context context)
{
	receiver = new BroadcastReceiver()
	{
		@Override
		public void onReceive(final Context context, Intent intent) 
		{
			String action = intent.getAction();
			
	        if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) 
	        {
	        	int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
	            int oldstate = intent.getIntExtra(WifiManager.EXTRA_PREVIOUS_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
	            if (oldstate != state)
	            {
	            	emptyList(pref);
	            	if (state == WifiManager.WIFI_STATE_ENABLED)
		            {
		        		fillList(pref, context);
		            }
	            }
	        } 
	        else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) 
	        {
		         SupplicantState state = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
		         if (state == SupplicantState.COMPLETED)
		         {
		        	 selectActive(pref, context);
		         }
	        }
		}
	};		
	
	context.registerReceiver(receiver, new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION));
	context.registerReceiver(receiver, new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
}
 
開發者ID:thunderace,項目名稱:mpd-control,代碼行數:36,代碼來源:WifiConnectionSettingsFragment.java

示例12: startServer

public void startServer(Handler handler, String documentRoot, int port) {
	try {
		isRunning = true;
		WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
		WifiInfo wifiInfo = wifiManager.getConnectionInfo();
		
		String ipAddress = intToIp(wifiInfo.getIpAddress());

		if( wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) {
			new AlertDialog.Builder(this).setTitle("Error").setMessage("Please connect to a WIFI-network for starting the webserver.").setPositiveButton("OK", null).show();
			throw new Exception("Please connect to a WIFI-network.");
		}
        
  server = new Server(handler, documentRoot, ipAddress, port, getApplicationContext());
  server.start();
  
     Intent i = new Intent(this, StartActivity.class);
     PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0);

     updateNotifiction("Webserver is running on port " + ipAddress + ":" + port);
     
 	Message msg = new Message();
 	Bundle b = new Bundle();
 	b.putString("msg", "Webserver is running on port " + ipAddress + ":" + port);
 	msg.setData(b);
 	handler.sendMessage(msg);
 	
	} catch (Exception e) {
		isRunning = false;
		Log.e("Webserver", e.getMessage());
     updateNotifiction("Error: " + e.getMessage());
	}
}
 
開發者ID:bodeme,項目名稱:androidwebserver,代碼行數:33,代碼來源:ServerService.java

示例13: onReceive

@Override
public void onReceive(final Context context, final Intent intent) {
    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    final WifiInfo info = wifiManager.getConnectionInfo();

    if (intent.getAction().equals(ACTION_NETWORK_TOGGLED)) {
        final String extra_ssid = intent.getStringExtra(EXTRA_SSID);
        if (!extra_ssid.equals(WifiPreferenceUtil.normalizeSSID(info.getSSID()))) {
            Log.d(TAG, "not connected to network [ " + extra_ssid + " ]");
            return;
        }
    }

    if (info.getSupplicantState() != SupplicantState.COMPLETED) {
        Log.d(TAG, "Wifi is not connected.");
        lockKeyguard(context);
        return;
    }

    Log.d(TAG, "Wifi is connected.");
    final WifiPreferenceUtil util = new WifiPreferenceUtil(context);
    final String ssid = info.getSSID();
    if (util.isKeyguardDisabledForNetwork(ssid)) {
        Log.d(TAG, "Unlocking keyguard for SSID: [ " + ssid + " ].");
        unlockKeyguard(context);
    } else {
        Log.d(TAG, "Locking keyguard for SSID: [ " + ssid + " ].");
        lockKeyguard(context);
    }
}
 
開發者ID:birbeck,項目名稱:wifikeyguard,代碼行數:30,代碼來源:WifiStateReceiver.java

示例14: isConnected

private static boolean isConnected(final SupplicantState ss) {
	return (ss == SupplicantState.COMPLETED);
}
 
開發者ID:rsalvaterra,項目名稱:Fon,代碼行數:3,代碼來源:FonManService.java

示例15: updateWifiAction

private void updateWifiAction(Menu menu, ProxyConfiguration pconf)
{
	menuItemWifiStatus = menu.findItem(R.id.menu_wifi_status);
	menuItemWifiToggle = menu.findItem(R.id.menu_wifi_toggle);
	menuItemWifiSettings = menu.findItem(R.id.menu_wifi_settings);

	// Wi-Fi Toggle
	boolean wifiEnabled = App.getWifiManager().isWifiEnabled();
	if (wifiEnabled)
		menuItemWifiToggle.setTitle(getResources().getString(R.string.wifi_toggle_off_summary));
	else
		menuItemWifiToggle.setTitle(getResources().getString(R.string.wifi_toggle_on_summary));

	// Wi-Fi Supplicant state
	SupplicantState ss = App.getWifiManager().getConnectionInfo().getSupplicantState();
	TraceUtils.d(TAG, "Supplicant state: " + ss.toString());

	if (wifiEnabled)
	{
		if (ss == SupplicantState.COMPLETED)
		{
			if (pconf.ap != null)
			{
				Drawable icon;

				if (pconf.ap.security == 0)
					icon = getResources().getDrawable(R.drawable.wifi_signal_open);
				else
					icon = getResources().getDrawable(R.drawable.wifi_signal_lock);

				icon.setLevel(pconf.ap.getLevel());
				menuItemWifiStatus.setIcon(icon);

				menuItemWifiSettings.setTitle(getResources().getString(R.string.connected_to, pconf.ap.ssid));
			}
			else
			{
				menuItemWifiStatus.setActionView(R.layout.actionbar_refresh_progress);
			}
		}
		else if (ss == SupplicantState.SCANNING) // Supplicant can remain
													// int SCANNING state
													// forever
		{
			menuItemWifiStatus.setIcon(getResources().getDrawable(R.drawable.ic_action_nowifi));
		}
		else
		{
			menuItemWifiStatus.setActionView(R.layout.actionbar_refresh_progress);
		}
	}
	else
	{
		menuItemWifiStatus.setIcon(getResources().getDrawable(R.drawable.ic_action_wifi_disabled));
	}

	// ss == SupplicantState.ASSOCIATED
	// ss == SupplicantState.ASSOCIATING
	// ss == SupplicantState.AUTHENTICATING
	// ss == SupplicantState.COMPLETED
	// ss == SupplicantState.DISCONNECTED
	// ss == SupplicantState.DORMANT
	// ss == SupplicantState.FOUR_WAY_HANDSHAKE
	// ss == SupplicantState.GROUP_HANDSHAKE
	// ss == SupplicantState.INACTIVE
	// ss == SupplicantState.FOUR_WAY_HANDSHAKE
	// ss == SupplicantState.INTERFACE_DISABLED
	// ss == SupplicantState.INVALID
	// ss == SupplicantState.SCANNING
	// ss == SupplicantState.UNINITIALIZED
}
 
開發者ID:shouldit,項目名稱:android-proxy,代碼行數:71,代碼來源:ProxyPreferencesActivity.java


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