Show Toast When There Is No Internet Access Android
how do i make this code run in background forever and always detect if there is internet access or not (not internet connection) and show a toast when there is no internet access?
Solution 1:
First of all, its bad idea to run this code forever in background.
Instead use BroadCastReceiver
to check network status, so it will only active at the time of network status change,
You have to register your BroadcastReceiver
for Network Status Change event. So whenver any changes happen on device for network android broadcast event and your BroadcastReceiver will listen that event and display Toast based on that.
Good tutorials: http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html
http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/
Post a Comment for "Show Toast When There Is No Internet Access Android"