Showing posts with label wifi. Show all posts
Showing posts with label wifi. Show all posts

Monday, May 02, 2016

iOS Boot Camp

If your company is planning to go into iOS development, the 5-Day iOS Boot Camp is the most cost-effective way to get your developers jumpstarted. Available in Swift or Objective-C, this course focuses on all the important aspects of iOS development to jumpstart your developers in the shortest time.  We can conduct this course in house, or you can send your developers to our open classes.

Topics include:

  • Introduction to Objective-C or Swift
  • Storyboard
  • Location-Based Services
  • Design Patterns
  • Protocols and Delegates
  • Databases
  • Web Services
  • Background Fetch
  • Network Connectivity

We have conducted this course successfully worldwide. Contact Wei-Meng Lee @ weimenglee@learn2develop.net for details such as costing, venue, as well as in-house arrangements.

Monday, January 19, 2015

Android Tip - Connecting to a Wireless Network Programmatically

If you want to programmatically set your Android device to connect to a particular wireless network, you can use the WifiConfiguration and WifiManager classes:

        EditText txtNetworkName = (EditText) 
            findViewById(R.id.txtNetworkName);
        EditText txtPassword = (EditText) 
            findViewById(R.id.txtPassword);

        WifiConfiguration wifiConfiguration = new 
            WifiConfiguration();
        wifiConfiguration.SSID = String.format("\"%s\"", 
            txtNetworkName.getText().toString());
        wifiConfiguration.preSharedKey = String.format("\"%s\"", 
            txtPassword.getText().toString());

        WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        int netId = wifiManager.addNetwork(wifiConfiguration);

        if (wifiManager.isWifiEnabled()) { //---wifi is turned on---
            //---disconnect it first---
            wifiManager.disconnect();
        } else { //---wifi is turned off---
            //---turn on wifi---
            wifiManager.setWifiEnabled(true);
        }
        wifiManager.enableNetwork(netId, true);
        wifiManager.reconnect();

The above code snippet connects to a WPA-secured wireless network. It first checks if WiFi is enabled, turn if on if it is not, and then connects to the specified network.

To do the above, you need the following permissions in your AndroidManifest.xml file:

    <!--you need this to check if wifi is enabled-->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!--you need this to use wifi to connect to a network-->
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />