Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I program android to look for a particular network? (Issues Following Simple Tutorial)
    primarykey
    data
    text
    <p>I'm attempting to use the following example:</p> <p><a href="https://stackoverflow.com/questions/11060414/how-do-i-program-android-to-look-for-a-particular-network">How do I program android to look for a particular network?</a></p> <p>But I'm unable to execute it due to issues stemming from the line:</p> <p>WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);</p> <p>After that I'm getting several other errors - but [I think] I've followed the tutorial/example precisely. </p> <pre><code>import java.util.List; import android.app.Activity; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; import android.os.Bundle; import android.util.Log; import android.content.Context; public class Connect extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.connect); String networkSSID = "ANDRE-PC_NETWORK"; String networkPass = "superman"; WifiConfiguration conf = new WifiConfiguration(); conf.SSID = "\"" + networkSSID + "\""; //ssid must be in quotes conf.wepKeys[0] = "\"" + networkPass + "\""; conf.wepTxKeyIndex = 0; conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); conf.preSharedKey = "\""+ networkPass +"\""; conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE); wifiManager.addNetwork(conf); List&lt;WifiConfiguration&gt; list = wifiManager.getConfiguredNetworks(); for( WifiConfiguration i : list ) { if(i.SSID != null &amp;&amp; i.SSID.equals("\"" + networkSSID + "\"")) { WifiManager.disconnect(); WifiManager.enableNetwork(i.networkId, true); WifiManager.reconnect(); break; } } }} </code></pre> <p>ISSUES IN ECLIPSE PROBLEM LOG:</p> <pre><code>Description Resource Path Location Type Cannot make a static reference to the non-static method reconnect() from the type WifiManager Connect.java line 41 Java Problem Cannot make a static reference to the non-static method disconnect() from the type WifiManager Connect.java line 39 Java Problem Cannot make a static reference to the non-static method enableNetwork(int, boolean) from the type WifiManager Connect.java line 40 Java Problem </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload