private boolean isInternetConnected( )
{
ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService
(CONNECTIVITY_SERVICE);
NetworkInfo networkInfo= connectivityManager .getActiveNetworkInfo();
if( networkInfo != null && networkInfo.isConnected( ) )
{
return true;
}
else
{
return false;
}
}
補充:
記得在AndroidManifest.xml裡加入
沒有留言:
張貼留言