January 20th, 2012, 03:46 PM
|
#3 (permalink)
|
|
New Member
Join Date: Nov 2010
Posts: 2
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
|
Got an android service running and first thing I would like it to do is check for a network connection, I found another snippet below but don't know how to pass a context to it??
private boolean isOnline(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERV ICE);
NetworkInfo network = cm.getActiveNetworkInfo();
if (network != null) {
return network.isAvailable();
}
return false;
}
if (isOnline(???))
{
//Code here
}
also this could be running long after the activity is destroyed, I am really not sure only started coding in Android 2 weeks ago.
Thanks for your help
|
|
|