I want to create an application for Android smartphones that checks if the phone is in Airplane Mode. If it is, the application gets the phone off the Airplane mode and checks if there is any network connectivity to send a SMS. When I say network connectivity, I mean mobile phone network coverage to send the SMS, I don't want to check for internet connectivity. If there is network connectivity the application will try to send a SMS.
I have managed to do the Airplane Mode check and toggle, but I don't find a way to see if the phone is connected to the cellular network and if there is coverage. I found many examples that check for internet network connectivity, but is not what I need.
Is there any way to check if the phone is connected to the cellular network and if there is coverage to send SMS?
Thanks in advance for your help.
Use this to check the signal strength:
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener signalListener = new PhoneStateListener() {
public void onSignalStrengthChanged(int asu) {
//asu is the signal strength
}
};
telephonyManager.listen(signalListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With