internet-connection

Detect if android device is connected to the internet

此生再无相见时 提交于 2019-12-05 16:13:07
this is my class that checks if the device is connected to the internet. import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.util.Log; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class ConnectionDetector { private Context _context; public ConnectionDetector(Context context) { this._context = context; } public boolean isConnectingToInternet() { if (networkConnectivity()) { try { HttpURLConnection urlc = (HttpURLConnection) (new URL( "http://www.google

Check whether Internet is on or off in Xamarin Android

自古美人都是妖i 提交于 2019-12-05 03:37:58
I am working on Xamarin Android Application.Before proceed to my next fragment I want to check Internet Connection and inform user about it ? How can i implement that ?And how to refresh whole fragment after user switch-on the internet? Any advice or suggestion will be appreciated ! Try this : NetworkStatus internetStatus = Reachability.InternetConnectionStatus(); if(!Reachability.IsHostReachable("http://google.com")) { // Put alternative content/message here } else { // Put Internet Required Code here } To get the network status you could use the following method in your activity: public bool

Consuming a web service through an internet proxy server, using a WCF client in C#; providing proxy server authentication

拟墨画扇 提交于 2019-12-04 12:06:27
问题 I have a client program that consumes a web service. It works quite well in a number of installations. Now I have a situation where a new customer connects to the internet via a proxy server, and my program's attempt to access the web service gets the "HTTP status 407: Proxy authentication required" error. I thought that all the configuring of internet access, including proxy server address, port number and authentication would be done in the Control Panel Internet Options, and that I wouldn

Windows Phone 8.1: Check Internet Connection

↘锁芯ラ 提交于 2019-12-04 07:34:50
How can I know if the phone has internet connection? (Whether WiFi or Data) Sometimes the phone is connecting to WiFi without internet connection like HotSpots. So I want a code to know if the phone is connecting to internet. You can simply try: if (NetworkInformation.GetInternetConnectionProfile() == null) { //no connection } As you can see in this msdn documentation: NetworkInformation.GetInternetConnectionProfile It will return null if there is "no connection profile with a suitable connection" You can also check explicity the "Internet Access" level with this: NetworkInformation

Is there any way to detect network connection type using javascript? [duplicate]

徘徊边缘 提交于 2019-12-04 03:42:42
问题 This question already has answers here : How do I check connection type (WiFi/LAN/WWAN) using HTML5/JavaScript? (4 answers) Closed 15 days ago . I would like to know is there any way to check if user is connected from 2G, 3G, 4G, or WiFi using javascript. As of my knowledge only Mozilla provides a Network Information API which helps to detect general connection type like 'wifi', 'cellular' etc. 回答1: It is a wrong approach to expose your network to javascript. Anyways for your better

Internet connection in android emulator always displays connected state

跟風遠走 提交于 2019-12-03 16:12:50
问题 I tried in many ways to check Internet connection in my android emulator ConnectivityManager conMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info= conMgr.getActiveNetworkInfo(); if(info != null || info.isConnected()) { Log.v("NetworkInfo","Connected State"); } else{ Log.v("NetworkInfo","Not Connected state"); Log.v("Reason",info.getReason()); } even if i disable Internet connection in my system ,my code seems to display Connected state so i guessed

ios: How to display “choose wireless connection” popup?

荒凉一梦 提交于 2019-12-03 14:25:10
If there is no internet connection and you start for example the safari app with Ipad or Iphone, a popup appears saying: "Choose wireless network" Is there a way to force this popup to show up in my app when I want to? The problem is, I have a button in my app which connects the user to facebook. After pressing the button the safari browser opens and shows the facebook authorization page. If there is no internet connection this popup appears, but there is no way to turn back to the app from there. So currently I check internet connection before allowing this authorization page to appear, but I

How can i check mobile data or wifi is on or off. ios swift

江枫思渺然 提交于 2019-12-03 13:55:46
问题 in my app i am checking that if mobile data is off its showing the popup like check your data connection. for that i write this code import Foundation import SystemConfiguration public class Reachability { class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let

Android Internet connectivity check better method

家住魔仙堡 提交于 2019-12-03 05:53:25
问题 According to the Android developer site, Determining and Monitoring the Connectivity Status , we can check there is an active Internet connection. But this is not working if even only Wi-Fi is connected and not Internet available (it notifies there is an Internet connection). Now I ping a website and check whether Internet connections are available or not. And this method needs some more processing time. Is there a better method for checking Internet connectivity than this to avoid the time

Internet connection in android emulator always displays connected state

梦想的初衷 提交于 2019-12-03 05:32:10
I tried in many ways to check Internet connection in my android emulator ConnectivityManager conMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info= conMgr.getActiveNetworkInfo(); if(info != null || info.isConnected()) { Log.v("NetworkInfo","Connected State"); } else{ Log.v("NetworkInfo","Not Connected state"); Log.v("Reason",info.getReason()); } even if i disable Internet connection in my system ,my code seems to display Connected state so i guessed this may work if ( conMgr.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED || conMgr