Search code examples
androidandroid-wifi

How do I send data only by WiFi


In my downloader I have to let the user choose whether he wants to download by WiFi or by using network connectivity. I know I can do this via:

final ConnectivityManager connMgr = (ConnectivityManager)
 this.getSystemService(Context.CONNECTIVITY_SERVICE);

final android.net.NetworkInfo wifi =
 connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);   

and then use the isConnected() method to see if I have WiFi connectivity. I also have another class named Sharable, not an Activity, which is supposed to hold all the data that is to be shared across Activities. These 'sharable' things include connections to database and so on.

How can I get this WiFi information in this Sharable class ?
Can this not be achieved without it extending Activity ?
If not, where am I supposed to instantiate the various variables ? In the onCreate?


Solution

  • Just pass Application context to Sharable.