internet-connection

How to check the internet connectivity within the network in Android (using internet of some other device through HOTSPOT)

血红的双手。 提交于 2019-11-30 04:48:56
I have a requirement where I want to check whether there is any internet connectivity when I am connected with the network. For example, I have device A and device B. Device A is connected with hotspot with that of device B. In device A, I get it as connected with Wi-Fi and in device B - one device connected with hotspot. Now, if I remove the internet from device B (not the tethering hotspot), then in device A, it still shows - connected with Wi-Fi but there is no internet connectivity. Classes like ConnectivityManager help in determining whether a device is connected with the network not

How do I disable the Internet connection in Android Emulator?

醉酒当歌 提交于 2019-11-30 04:12:30
I am trying to check Internet connectivity on Android using the following method. I have a Wi-Fi connection. private boolean checkInternetConnection() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // Test for connection if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) { return true; } else { // No conection return false; } } I disconnect my PC from the Internet and then try to run the above method. Still it always returns true!? Why? MKJParekh From Eclipse To disable

Objective-C determine data network type of the iOS device

不问归期 提交于 2019-11-29 20:38:51
Im on an application that receive data from server, the problem is when user connect to cellular data (Not 3G or WIFI ), it take ages to receive data. i had implemented this code from this Answer but im not sure if it is effective or not, sometimes it's giving me an accurate type, and sometimes it don't. here is my code: - (void)newtworkType { NSArray *subviews = [[[[UIApplication sharedApplication] valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews]; NSNumber *dataNetworkItemView = nil; for (id subview in subviews) { if([subview isKindOfClass:[NSClassFromString(@

Check internet connection in android (not network connection)

旧街凉风 提交于 2019-11-29 16:03:03
I have a problem with checking internet connection in android at runtime. I use some different methods to check internet connection but i don't know which one is better . because each of them have some problems . Method 1 check internet connection by pinging Google : Runtime runtime = Runtime.getRuntime(); try { Process mIpAddressProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8"); int mExitValue = mIpAddressProcess.waitFor(); return mExitValue == 0; } catch (InterruptedException | IOException ignore) { ignore.printStackTrace(); } Method 2 check internet connection by ConnectivityManager :

How do I disable the Internet connection in Android Emulator?

余生颓废 提交于 2019-11-29 02:06:54
问题 I am trying to check Internet connectivity on Android using the following method. I have a Wi-Fi connection. private boolean checkInternetConnection() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // Test for connection if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) { return true; } else { // No conection return false; } } I disconnect my PC from the Internet and

ANDROID: if WiFi is enabled AND active, launch an intent

无人久伴 提交于 2019-11-28 17:06:26
This is what I would like to do : => IF WiFi is enabled AND active, launch an intent (in fact it's a WebView that gets its content=>the instructions of my app on the web) => IF NOT, then I would launch another intent so that I don't show a WebView with "Web page not available ... The Web page at http://www.mywebsite.com might be temporarily down or it may have moved ..." I tought initially to use if(wifi.isWifiEnabled()) but that does not say if the Wifi connection is ACTIVE or not. It says only that the user has turned the switch on. The device may or may not be connected... Is this correct ?

Objective-C determine data network type of the iOS device

淺唱寂寞╮ 提交于 2019-11-28 16:21:18
问题 Im on an application that receive data from server, the problem is when user connect to cellular data (Not 3G or WIFI ), it take ages to receive data. i had implemented this code from this Answer but im not sure if it is effective or not, sometimes it's giving me an accurate type, and sometimes it don't. here is my code: - (void)newtworkType { NSArray *subviews = [[[[UIApplication sharedApplication] valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews]; NSNumber

Check if Internet Connection Exists with Ruby?

旧街凉风 提交于 2019-11-28 07:34:28
Just asked how to check if an internet connection exists using javascript and got some great answers. What's the easiest way to do this in Ruby? In trying to make generated html markup code as clean as possible, I'd like to conditionally render the script tag for javascript files depending on whether or not an internet condition. Something like (this is HAML): - if internet_connection? %script{:src => "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", :type => "text/javascript"} - else %script{:src => "/shared/javascripts/jquery/jquery.js", :type => "text/javascript"} You can

Is it possible to share my internet connection from pc to android via usb? [closed]

徘徊边缘 提交于 2019-11-28 01:15:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I've an Asus eee pad connected to my PC using USB. I want to use the PC Internet on my Android device. How can I use PC Internet Connection from Android Device via USB? Thanks in advance, 回答1: Yes, it's possible. There's a guy on XDA forum who develop the reverse tethering method, which could let you surf on

Check internet connection (iOS 10)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 19:07:40
问题 For iOS 9 I was using Reachability public class to check wether the device is connected to the internet or not. I converted my Swift 2 code to Swift 3, and the Reachability doesn't work anymore. Can someone tell me how to check the internet connection on iOS 10? Thanks! Here's the code snippet: open class Reachability { class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in() zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress)) zeroAddress.sin_family = sa