You want to use a WifiManager instead the TelephonyManager to find out about the WifiConnection state.
Use the following APIs below private WifiManager mWifiMgr; mWifiMgr = (WifiManager)mContext.getSystemService(mWifiService); mWifiMgr.getConnectionInfo(); If you are interested to find out in general whether you are connected using a radio interface you also can use the ConnectionManager. Hope, this helps. -- Roman Baumgaertner Sr. SW Engineer-OSDC ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Aug 12, 7:35 am, SkySte <ste.is....@gmail.com> wrote: > Hi, My Java knowledge is very limited so it's quite an easy question > (probably) but how can I get the code below to work? I'm basically > trying to check that the device is connected to the internet to that I > can access and parse an RSS feed. This is also the 1st android app I > have written so I'm still finding my way around so any help/advice > would be appreciated. > > I'm sure the variables should be assigned to something but I don't > know what. The classes don't appear to have public constructors so I > can't do "WifiInfo info = new WifiInfo()" > > package com.Weather; > import android.net.wifi.WifiInfo; > import android.widget.Toast; > import android.telephony.TelephonyManager; > > public class AirportWeather { > > public AirportWeather() { > > } > > /** > * Check the device is connected to the internet > * @return int 1 = connected, 0 = not connected > */ > private static int checkInternetStatus() > { > WifiInfo info; > TelephonyManager data; > Toast.makeText(null, info.getNetworkId(), 200); > if(data.getDataState() == 2) > //mobile network is connected then return 1) > { > return 1; > }else if(info.getNetworkId() != 0) > { > return 1; > } > return 0; > } > > } > > Thanks > Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---