-1

I'm new in java and i want to know if my phone lost the wi-fi connection more than 10 sec to send an sms with his GPS information (for an application that make a http page with location and sensor data that the pc request). I just don't know how to proceed, is there an OnStateChange or something ? And how must I implement that code : http://developer.android.com/reference/android/net/NetworkInfo.DetailedState.html for doing that ?

Thanks to reply.

4

2 に答える 2

1

こちらです:

public static boolean isInternetAvailable(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
        return true;
    }
    return false;
}
于 2013-10-25T12:48:55.057 に答える