कुछ अच्छे नेटवर्क उपयोग कार्यों के नीचे संलग्न किया गया है जो मैं अपने ऐप्स में उपयोग कर रहा हूं, सभी आकर्षण जैसे आकर्षण! और स्थान मतदान, निश्चित रूप से के लिए ->https://github.com/commonsguy/cwac-locpoll
आशा है कि यह मदद करता है ...
public static boolean checkInternetConnection(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
// ARE WE CONNECTED TO THE NET?
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
return true;
} else {
Log.w(TAG, "Internet Connection NOT Present");
return false;
}
}
public static boolean isConnAvailAndNotRoaming(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
if(!conMgr.getActiveNetworkInfo().isRoaming())
return true;
else
return false;
} else {
Log.w(TAG, "Internet Connection NOT Present");
return false;
}
}
public static boolean isRoaming(Context context) {
ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
return (conMgr.getActiveNetworkInfo()!=null && conMgr.getActiveNetworkInfo().isRoaming());
}