TrafficStats can tell you the number of bytes/packets/etc. transferred over WiFi or mobile data.
On Mon, Jan 16, 2012 at 6:49 AM, Put_tiMe <[email protected]> wrote: > I want to determine if the Wifi is being used currently. > > AFAIK, Wifi can be in a "connected" state, but there need not be any > data being transferred currently. > > I can get whether the Wi-fi is connected or not by doing this: > > -------------------------------------------------------------------------------------------------------------------------------- > android.net.ConnectivityManager pCM = > (android.net.ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); > if(null != pCM) > { > NetworkInfo aNI = > pCM.getNetworkInfo(android.net.ConnectivityManager.TYPE_WIFI); > if(null != aNI) > { > NetworkInfo.DetailedState aDS = > aNI.getDetailedState(); > > if(NetworkInfo.DetailedState.IDLE == > aDS || > NetworkInfo.DetailedState.FAILED == aDS || > > NetworkInfo.DetailedState.DISCONNECTED == aDS || > NetworkInfo.DetailedState.SUSPENDED == aDS) > { > WifiManager > theWiFi = > (WifiManager)getSystemService(WIFI_SERVICE); > > if(null != theWiFi) > { > // do something > } > } > else > { > // do something > } > } > } > -------------------------------------------------------------------------------------------------------------------------------- > > But I am not able find an API if the Wifi data transfer is happening. > Is there any way I can know this? > > Thanks > > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in DC: http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

