Currently I am looking for a concrete solution for getting the Cellular Network availability. For this I want share a scenario: Suppose I am getting Cellular connection but data connection is disabled in that case it should give me positive result but while I am out of coverage area or airplane mode is ON it should return false. I have tried few codes from stackoverflow :like Check Network connections in android and Check mobile network connectivity & What does NetworkInfo.State SUSPENDED indicate? but still they are not what I am looking for. Few of the other codes I tried are :
public String getCellularState(Context context){
if(mPhoneState!=null && mPhoneState.getState()==ServiceState.STATE_IN_SERVICE){
return "Available";
}
else{
return "Not Available";
}
}
and also
public String getOperator()
{
TelephonyManager manager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
opeartorName = manager.getSimOperator();
return opeartorName;
}
but got no success, Please suggest the right way and also don't relate this to Data Connection