how to check wifi connection throught the entire application.is there any events or class that we can get message for that? th开发者_开发知识库ankx
See this question for details of how to check wifi status.
Do be aware that even if the wifi is switched on, and connected to a wifi network, that doesn't guarantee data can be transmitted and received - the signal may be too weak for example at the moment you try to use it. So don't assume connections will definitely work because the wifi is connected.
Take a look at WifiManager class.
Also here is a nice article with code samples.
I use a super class that I extend all Activity
classes from. It shows an alert when connectivity is lost and stays that way until connectivity is restored. You can edit it to add anything you want.
I have it at : https://github.com/sfarooq/A-droid-lib
精彩评论