I need to detect when the GSM phone has just been connected to the Network(from cell tower not available to cell tower connected). For this i set broadcast reciever
AIRPLANE_MODE (turns off) and BOOT_COMPLETE, when these two get fired i will loop for a while until Network is detected. But aside from this the phone might be in a location where
Cell Tower is simply not available
how can i detect such a situation?
You can use a BroadcastReceiver set up with an intent filter for “android.net.conn.CONNECTIVITY_CHANGE”
In that receiver, you can look at the intent’s extras to figure out if you have a connection or not. I do it as follows:
If that second if check is true that means there’s no network connection, so the receiver exits. Next time there’s a connectivity change, the receiver is activated again and runs this check again. Once it passes the check, then I proceed to do whatever I do.