You can check if the Data Connection is enabled or not on the device:
public boolean isDataConnectionAvailable(Context context){
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
if(info == null)
return false;
return connectivityManager.getActiveNetworkInfo().isConnected();
}
Permission:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
No comments:
Post a Comment