Java Code Examples for com.gizwits.opensource.appkit.CommonModule.WifiAutoConnectManager

The following examples show how to use com.gizwits.opensource.appkit.CommonModule.WifiAutoConnectManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void onReceive(Context context, Intent intent) {

	spf = context.getSharedPreferences(GosBaseActivity.SPF_Name, Context.MODE_PRIVATE);

	String wifiname = spf.getString("workSSID", "");
	String wifipass = spf.getString("workSSIDPsw", "");
	String connectWifiSsid = NetUtils.getConnectWifiSsid(context);
	if (connectWifiSsid != null && connectWifiSsid.contains(GosBaseActivity.SoftAP_Start)) {
	} else {

		if (connectWifiSsid.contains(wifiname)) {

			return;
		}
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(wifiname, wifipass, WifiAutoConnectManager.getCipherType(context, wifiname));
	}
}
 
Example 2
Source Project: Gizwits-SmartBuld_Android   Source File: GosWifiChangeReciver.java    License: MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	spf = context.getSharedPreferences(GosBaseActivity.SPF_Name, Context.MODE_PRIVATE);

	String wifiname = spf.getString("workSSID", "");
	String wifipass = spf.getString("workSSIDPsw", "");
	String connectWifiSsid = NetUtils.getConnectWifiSsid(context);
	if (connectWifiSsid != null && connectWifiSsid.contains(GosBaseActivity.SoftAP_Start)) {
	} else {

		if (connectWifiSsid.contains(wifiname)) {

			return;
		}
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(wifiname, wifipass, WifiAutoConnectManager.getCipherType(context, wifiname));
	}
}
 
Example 3
Source Project: gokit-android   Source File: GosWifiChangeReciver.java    License: MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	spf = context.getSharedPreferences(GosBaseActivity.SPF_Name, Context.MODE_PRIVATE);

	String wifiname = spf.getString("workSSID", "");
	String wifipass = spf.getString("workSSIDPsw", "");
	String connectWifiSsid = NetUtils.getConnectWifiSsid(context);
	if (connectWifiSsid != null && connectWifiSsid.contains(GosBaseActivity.SoftAP_Start)) {
	} else {

		if (connectWifiSsid.contains(wifiname)) {

			return;
		}
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(wifiname, wifipass, WifiAutoConnectManager.getCipherType(context, wifiname));
	}
}
 
Example 4
private void readyToSoftAP() {

		// 切换至设备热点
		WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
		WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(softSSID, SoftAP_PSW, cipherType);
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

		workSSID = spf.getString("workSSID", "");
		workSSIDPsw = spf.getString("workSSIDPsw", "");
		final Timer mtimer = new Timer();
		mtimer.schedule(new TimerTask() {

			@Override	
			public void run() {
				if (progressDialog.isShowing()) {
					progressDialog.cancel();
					mtimer.cancel();
					String failText=(String) getText(R.string.configuration_failed);
					Message msg=new Message();
					msg.what=handler_key.FAILED.ordinal();
					msg.obj=failText;
					handler.sendMessage(msg);
				} else {
					mtimer.cancel();
				}
			}
		}, 10 * 1000);
		isChecked = true;
		while (isChecked) {
			String presentSSID = NetUtils.getCurentWifiSSID(GosConfigCountdownActivity.this);
			if (!TextUtils.isEmpty(presentSSID) && presentSSID.contains(SoftAP_Start)) {
				if (checkNetwork(GosConfigCountdownActivity.this)) {
					
					progressDialog.cancel();
					isChecked = false;
					handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
					GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
							GizWifiConfigureMode.GizWifiSoftAP, presentSSID, 60, null);
				//	handler.sendEmptyMessageDelayed(handler_key.OFFTIME.ordinal(), 2000);
				}
				if(broadcase==null){
					broadcase = new GosWifiChangeReciver();
					registerReceiver(broadcase, filter);
				}
				
			}
		}
	}
 
Example 5
private void readyToSoftAP() {

		// 切换至设备热点
		WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID);
		manager.connect(softSSID, SoftAP_PSW, cipherType);
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

		workSSID = spf.getString("workSSID", "");
		workSSIDPsw = spf.getString("workSSIDPsw", "");
		final Timer mtimer = new Timer();
		mtimer.schedule(new TimerTask() {

			@Override
			public void run() {
				if (progressDialog.isShowing()) {
					progressDialog.cancel();
					mtimer.cancel();
					handler.sendEmptyMessage(handler_key.FAILED.ordinal());
				} else {
					mtimer.cancel();
				}
			}
		}, 10 * 1000);
		isChecked = true;
		while (isChecked) {
			String presentSSID = NetUtils.getCurentWifiSSID(GosConfigCountdownActivity.this);
			if (!TextUtils.isEmpty(presentSSID) && presentSSID.contains(SoftAP_Start)) {
				if (checkNetwork(GosConfigCountdownActivity.this)) {
					GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
							GizWifiConfigureMode.GizWifiSoftAP, presentSSID, 60, null);
					progressDialog.cancel();
					isChecked = false;
					handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
				}
				registerReceiver(broadcase, filter);
			}
		}
	}
 
Example 6
Source Project: gokit-android   Source File: GosConfigCountdownActivity.java    License: MIT License 4 votes vote down vote up
private void readyToSoftAP() {

		// 切换至设备热点
		WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(softSSID, SoftAP_PSW, cipherType);
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

		workSSID = spf.getString("workSSID", "");
		workSSIDPsw = spf.getString("workSSIDPsw", "");
		final Timer mtimer = new Timer();
		mtimer.schedule(new TimerTask() {

			@Override	
			public void run() {
				if (progressDialog.isShowing()) {
					progressDialog.cancel();
					mtimer.cancel();
					String failText=(String) getText(R.string.configuration_failed);
					Message msg=new Message();
					msg.what=handler_key.FAILED.ordinal();
					msg.obj=failText;
					handler.sendMessage(msg);
				} else {
					mtimer.cancel();
				}
			}
		}, 10 * 1000);
		isChecked = true;
		while (isChecked) {
			String presentSSID = NetUtils.getCurentWifiSSID(GosConfigCountdownActivity.this);
			if (!TextUtils.isEmpty(presentSSID) && presentSSID.contains(SoftAP_Start)) {
				if (checkNetwork(GosConfigCountdownActivity.this)) {
					GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
							GizWifiConfigureMode.GizWifiSoftAP, presentSSID, 60, null);
					progressDialog.cancel();
					isChecked = false;
					handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
				}
				if(broadcase==null){
					broadcase = new GosWifiChangeReciver();
					registerReceiver(broadcase, filter);
				}
				
			}
		}
	}