Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to check if wifi/3g is enabled?
    primarykey
    data
    text
    <p>I have a button that presents some RSS news. My problem is that I would like to present a toast message "there is no internet connection" if the wifi is disabled or there is no 3g connection. I have to make it work if the wifi is closed to pop out the message but my problem is:</p> <blockquote> <p>I want the application to check if the user has wifi enabled or 3g connection. If there is 3g to go the new activity, if there is wifi to check not only if it is enabled but if the user is connected to a network and then go to the new activity. If the 3g or the wifi is disabled, I just want to present the message I wrote before.</p> </blockquote> <p>This is the code I have written as now but I don't really know how to continue...</p> <p>The manifest:</p> <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK"&gt;&lt;/uses-permission&gt; </code></pre> <p>And the source for my <code>onCreate</code> method:</p> <pre><code>@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main2); wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); if (wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); // an einai anoixto asto anoixto } else { Toast.makeText(nea.this, "Χρειάζεστε σύνδεση στο internet", Toast.LENGTH_SHORT).show(); finish(); } loadFeed(ParserType.DOM); } </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.
 

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