w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Check if device has internet connection
Put this method in the class you want to check connectivity: public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { return true; } return false; } Then when you need to check connection, do this (using your example): if(isOnline(getApplicationContext()){ webview.loadUrl("http://the.url.com") } else{ Toast.makeText(context, text, duration).show() } You can also create that method in a class and always use it from there, like ExampleClass.isOnline(). Do not forget to add this to your AndroidManifest: <uses-permission android:name="android.permissi

Categories : Java

Save FORM data on client PC when Internet connection is lost
Finally i found the answer, all thanx to viralpatel. answer: http://viralpatel.net/blogs/create-zip-file-javascript in the above i can create zip file inside which i can save any format file like(.txt or .xml ) with data.

Categories : Javascript

How can I send http messages from android app( physical device) to my local server without using internet connection?
Assuming that your devices are on the same Network (connected to the same router) as your computer, you can expose your computer's web server (Apache, presumably?) and then point your app directly at the local network IP address that your computer has (usually something like 192.168.1.x). I have found that the least painless way to do this is to use MAMP or WAMP or LAMP depending on your OS, but of course I have no idea what your specific situation is, so that solution may in fact make things a lot more complicated rather than less. In any event... your computer is on the network at a specific IP address, so it's just a matter of making sure that it's willing to serve this data on whatever port you are looking for it on. If you provide more specification as to your circumstances, we can

Categories : Android

No internet access on Android Emulator, Shared Internet Connection
Finally I sorted out my problem. It was problem due to dns server address. I did below steps open CMD Goto your android-sdk/tools path, Like my path is G:Andriod Developmentandroid-sdk ools type this command G:Andriod Developmentandroid-sdk ools>emulator.exe -avd Android_2.3.3 -dns-server 8.8.8.8 -scale 0.75 here Android_2.3.3 is your AVD name, -dns-server 8.8.8.8 will set your DNS address to 8.8.8.8 or 8.8.8.8:55 and -scale will scale your AVD to specified value. this will start a new emulator. Enjoy :) Hope may be helpful to others

Categories : Android

Can android differentiate between a lost internet connection and no internet connect?
You need to use a BroadcastReceiver that will be triggered when the connectivity status for Wi-Fi has changed. Set following things before registering BroadcastReceiver: private class ConnectionChangeReceiver extends BroadcastReceiver { public void onReceive( Context context, Intent intent ) { Log.d(tag, "Inside Broadcast Reciever"); CheckWifiStatus(); } } private void RegisterWifiWatcher() { if(wifiWatcher == null) wifiWatcher = new ConnectionChangeReceiver(); final IntentFilter intentFilter= new IntentFilter(); intentFilter.addAction("android.net.wifi.WIFI_STATE_CHANGED"); intentFilter.addAction("android.net.wifi.STATE_CHANGE"); registerReceiver(wifiWatcher, intentFilter); } WIFI_STATE_CHANGED : Broadcast intent action indicating that Wi-Fi has been enabled,

Categories : Android

RODBC connection- limited rows
I think RODBC acts poorly with Netezza. A solution http://datamining.togaware.com/survivor/Database_Connection.html just add believeNRows=FALSE to either your sqlQuery or odbcConnect call (use the later if you also use sqlFetch.

Categories : R

How to check host connection with internet connection
use this method : public static boolean isInternetConnected(Context context) { final ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); final Dialog dialog = new AlertDialog.Builder(context).setIcon(R.drawable.ic_launcher).setTitle("Connection Error!!") .setMessage("Internet Connection not found. Check your settings.").setNegativeButton("ok", null).create(); if (activeNetwork != null && activeNetwork.isConnected()) return true; else dialog.show(); return false; } If you don't want to show the toast comment it. Don't forget to place permission in manifest file. Here is the permission : <uses-permission a

Categories : Android

What are some methods of initializing server-client connections to an android client device?
Google Cloud Messaging GCM. It's free. It's unlimited. It's maintained by Google. And it's already installed on user's phones. That being said, the ideal way now is to use Google Play Services and have people login with their Google+ accounts. Watch the last Google I/O 2013 session on Google Play Services. The demo went wrong during the general keynote, but it works fine otherwise. Google Play Services takes care of all the networking issues for you (and also falls back to local wifi if users are on the same network). The price you have to pay is that you must force your users to use Google+ if they want that multiplayer functionality.

Categories : Android

c++ server doesn't close TCP socket connection after the connection process is killed on client
The default values for TCP keepalive are around 2 hours (in BSD/Linux implementations). Are you sure you have TCP keeaplives options set when you are seeing connectoins still up after 10 hours? I am thinking that your application perhaps is not explicitly setting the keepalive option. One way would be to use get socket option and pass SO_TCPKEEPALIVE to check if the keepalive is indeed set. And if it is not set, then please go ahead and set it. You might find this discussion helpful: How to use SO_KEEPALIVE option properly to detect that the client at the other end is down?

Categories : C++

Jersey as REST client, maintaining a connection (or validating connection)
The underlying connections are opened for each request and closed after the response is received and entity is processed (entity is read). final WebTarget target = ... some web target Response response = target.path("resource").request().get(); System.out.println("Connection is still open."); System.out.println("string response: " + response.readEntity(String.class)); System.out.println("Now the connection is closed."); If you don't read the entity, then you need to close the response manually by response.close(). Also if the entity is read into an input stream (by response.readEntity(InputStream.class)), the connection stays open until you finish reading from the InputStream. In that case, the InputStream or the Response should be closed manually at the end of reading from InputStre

Categories : Rest

viewWithTag can Use limited Time
Sound like you forgot to reset your image try this: UIImageView *hideFullImage = (UIImageView *)[self.view viewWithTag:sender+20]; [hideFullImage removeFromSuperView]; [hideFullImage setTag:sender+10]; hideFullImage.hidden = YES;

Categories : IOS

Client Socket Connections Being Denied By Server on Windows Host For Small Number (16 < x < 24) of Simulataneous Client Connection Attempts
I would check how many connections are in the TIME_WAIT state of the TCP connection. I have seen this type of problem due to many connections being open/closed causing socket exhaustion due to the TIME_WAIT. To check it, run: netstat -a

Categories : Java

Running a piece of code for a limited time
Set the timeout for socket before accept as follows serverSocket.setSoTimeout(10000); // 10 secs. time is in milisecs. socket=serverSocket.accept(); This will block accept for 10 secs if no client it moves on. But if you are planning to keep open the server socket, then create a new thread for accepting the client.

Categories : Java

Android: connecting two device without internet
Socket connection would be a great idea in your situation, you dont need to have Internet to do so. Here is one of many examples if you google it: http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/ Hope this helps

Categories : Android

Best approach to doing something once an Internet connection becomes available
This is roughly based on your "best idea". Tony Million's Reachability also posts notifications via NSNotificationCenter when the internet connection changes. All your classes that need to do something when an internet connection becomes available, should register for this notification. On the GitHub page there is an example for that: https://github.com/tonymillion/Reachability#another-simple-example You would initialize the Reachability class in your app delegate, like you do right now. And then your other classes register for the kReachabilityChangedNotification notification with the NSNotificationCenter in their initializer. They also have to deregister from the NSNotificationCenter in their dealloc method. Here is some code you can use as starting point: - (void)registerForReachabi

Categories : IOS

Is this possible to use recaptcha without internet connection
Recaptcha is a service. Each request is handled by a foreign server, so no chance without an internet connection. btw: A website without internet connection is not a real scenario ;) If you use external services, you must have a chance to reach them.

Categories : PHP

How to check internet connection with c?
InetnetCheckConnection causes linking error because you probably(certainly) didn't link Wininet.lib http://msdn.microsoft.com/en-us/library/windows/desktop/aa384346%28v=vs.85%29.aspx

Categories : C

How to work when internet connection down?
HTML5 has some offline capabilities. http://www.html5rocks.com/en/features/offline But do you really have a business case for this? It will get complicated when you need to try and update stale data etc.

Categories : Asp Net

Using svn on an unreliable internet connection
As far as I know, there aren't any commands that are connection-resilient. You could checkout the source code piecemeal, one folder at a time using sparse directories, but unfortunately you might still receive errors: svn co the folder structure: svn checkout http://svn.apache.org/repos/asf/subversion/trunk --depth immediates Then svn up each folder in turn: svn up --set-depth infinity build svn up --set-depth infinity contrib etc. And then set the depth of the parent folder to infinity so that subsequent updates retrieve changes for every folder, recursively: svn up --set-depth infinity A bit unwieldy, but it might reduce your frustrations with your unreliable internet connection.

Categories : Svn

Check for Internet connection in C++?
Personally I think I would solve this in one (or a combination) of the following two approaches. Make a timer with a callback function that checks internet connectivity every x second. Simply check internet access before every communication block and raise an exception if no access is available at given time. You might want to read a similar discussion for C# How to query internet connection status in C# ?

Categories : C++

Why does LocationListener need an internet connection
No Getting GPS doesn't need internet necessarily. But Getting correct coordinates using GPS in a stable, working and compatible way is a mess. Often you switch between providers and make use of internet to give good estimates IF GPS isn't responding very well. Make sure GPS is working and found a nice signal, because the internet can increase GPS initializing speed. GPS is really slow to load. It may take 6 to 8 minutes, especially if coverage is poor. Only after the GPS has actually determined its position. During the first few minutes you won't see anything, since no updates have occurred. Maybe you use NETWORK_PROVIDER in stead of GPS_PROVIDER. Like this locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); Try using: locationManage

Categories : Android

Best way to make sure content is ready to serve in a time limited environment?
You need to delay the execution of your game loop until all the required assets are loaded. Hopefully your code is already modular enough to allow for this. The browser fires an event when the resource located at the src of an image element has been downloaded. Using this event, you can create a basic preloading solution: var img = new Image(); img.onload = function() { console.log('Image loaded!'); }; img.src = '/images/my-image.jpg'; Expand this solution to iterate over all your assets. Once they're loaded, call the code that begins your game loop. There are a number of prebuilt solutions available: http://www.createjs.com/#!/PreloadJS http://thinkpixellab.com/pxloader/ https://github.com/nandastone/precook-backbone

Categories : Javascript

Can the the number of respawns within a time frame for Ruby's Unicorn be limited?
I've decided to give up on an answer for now. Instead I will preload the app to prevent the child spawn loop. From the Unicorn docs: Improperly deployed applications can go into a spawn loop if the application fails to load. While your children are in a spawn loop, it is is possible to fix an application by properly deploying all required code and dependencies. Using preload_app=true means any application load error will cause the master process to exit with an error.

Categories : Misc

PHPSESSID changes in every request ONLY under one internet connection
Things to check: Is the time (and time zone!) set correctly on those computers? If it's set incorrectly, they may be discarding session cookies prematurely (possibly even immediately). Is any odd security or "privacy" software installed on the computers? If possible, check if the issue persists under another browser on those machines. Are these computers behind any sort of web proxy? If so, it may be meddling with cookies.

Categories : PHP

SQL Connection Over Internet: good practice?
No, exposing your SQL server over the internet is not a good idea. That doesn't stop you from doing it, but: I wouldn't recommend it, unless the data is freely available and public domain (so it doesn't matter if someone gets access to more than you expected), and is trivial to replace (so it doesn't matter if it gets damaged). And even then I'd probably suggest using a service tier and keeping your database server strictly on the "inside". Re encryption: that prevents intermediaries from snooping, but it doesn't limit what the user can do. A malicious user with genuine access could simply connect up and do whatever they want, bypassing whatever rules and filters you have in place.

Categories : C#

iOS app freeze during checking internet connection
When you are requesting to the server then reduce the timeoutInterval option and set it to minimum so that request should not wait for long to get the response by this way you can reduce the time of freezing the app. If you want to get rid of it completely then you should run all the process for network check in on another thread possibly in background thread.

Categories : IOS

how to detect that user internet connection is on?
Using this You can check Connection System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() EXAMPLE:-- public static void testInternetConnection() { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { System.Windows.MessageBox.Show("This computer is connected to the internet"); } else { System.Windows.MessageBox.Show("This computer is not connected to the internet"); } }

Categories : Asp Net

Internet connection not working on some networks
most probably,open Internet is not available on your University /Office network or might be the url you are trying to access is blocked on these networks. Try to browse the same url through Browser App in your phone. This will give you a better picture of the problem.

Categories : Android

Phonegap check internet connection
You can check the connection like this: function CheckConnection() { if( !navigator.network ) { // set the parent windows navigator network object to the child window navigator.network = window.top.navigator.network; } // return the type of connection found return ( (navigator.network.connection.type === "none" || navigator.network.connection.type === null || navigator.network.connection.type === "unknown" ) ? false : true ); } returns true for connection and false for no connectivity. In Android Manifest, use the following permission: <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> Edit: Handles windows in iframes as well. Added a

Categories : Android

Socket connection works over LAN but not WAN (internet)
Is this using TCP or UDP? TCP What does this mean for what I am trying to do. Does anyone have any tips about how to get this to work? See below. Is it a matter of the port not being open? Most likely, but you should be able to get more detail from your IOException to confirm the cause. In this question I have answered provided details on port forwarding that you may find useful; C++ Sockets with Router You may also need to configure a firewall to allow ports external access depending on your environment.

Categories : Java

NSJSONSerialization terminates app if no internet connection
If you have no internet connection, your response object will be nil. With so, your NSJSONSerialization call will raise an exception, since the first parameter is nil. You should check if response is nil before assuming you can instantiate a JSON with it.

Categories : IOS

Python: checking internet connection (more than once)
This is how I used to check my connectivity for one of my applications. import httplib import socket test_con_url = "www.google.com" # For connection testing test_con_resouce = "/intl/en/policies/privacy/" # may change in future test_con = httplib.HTTPConnection(test_con_url) # create a connection try: test_con.request("GET", test_con_resouce) # do a GET request response = test_con.getresponse() except httplib.ResponseNotReady as e: print "Improper connection state" except socket.gaierror as e: print "Not connected" else: print "Connected" test_con.close() I tested the code enabling/disabling my LAN connection repeatedly and it works.

Categories : Python

iOS reachability says reachable with no internet connection on 3g
After quite a few a few days of research I found a solution that was useful for me and hopefully somebody in the future might find it useful. I created a singleton class with the above reachability code so that I could use it and check it whenever I make web calls easily. Although this did not solve my issue as I mentioned before but this is the first check. Then I went ahead and just did the regular stuff to get data from the url NSdata * data [NSData dataWithContentsOfURL:myurlhere]; if([data length] == 0) { show alert view here } else { doing stuff with the items in data } So using a combination of reachability (this does not always work in some cases like mine where a cellular network uses 3g or 4g) and checking the data downloaded can serve as a good check point for the

Categories : IOS

How to enable certain Internet connection in Android app?
I'm not sure you can do this programatically within the app but you can present the user with a button to open wireless settings so they can enable/disable one or the other. That's covered here: Ask user to start WiFi or 3G on launching an android app if not connected to Internet Also, it is possible to restrict apps from using mobile data and force them to use only WiFi in the Android settings menu. Go to Settings -> Data Usage -> Select the app -> Restrict Background Data. This will only allow the app to use WiFi data and the restriction is at the OS level. I hope these help!

Categories : Android

Best UI design to handle no internet connection
There can be several options Option 1: Use AlertDialog to show the disconnection. Set it to non cancelable and with two buttons like retry and exit. Option 2: start disconnection activity using start activity for result if the network disconnection occurs. In the new activity there is a retry button. If retry is set the set OK and finish. And if back button press set CANCEL. now in first activity in onActivityResult if you get RESULT_OK then retry connection.

Categories : Android

expecting a change of internet connection
You should use this ((Activity) context).startActivityForResult(i, 0); then you can use onActivityResult in your Activity1 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //Check result }

Categories : Eclipse

Close Application if no internet connection
Try this code. put following condition in onCreate(). if(!Utils.isOnline(mContext)){ Toast.makeText(getApplicationContext(), "You have no Internet Connection!", Toast.LENGTH_SHORT).show(); Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); finish(); }

Categories : Android

How App in background can check for internet connection, IOS?
i came to handle the same scenario when i was on a project but i came to know that By default in the background state app stays for a short time only, most apps move to the suspended state shortly afterward. That mean the app is in the background but is not executing code. So your custom implemented notification do not work. Must requery NetworkReachability at Wakeup Time in app delegate methodes: applicationWillEnterForeground: applicationDidBecomeActive this was the best i did to handle that problem, hope it helps

Categories : IOS

Do PhoneGap Apps need Internet connection?
PhoneGap apps can get all of their content from the local device, which means that if you store the assets within the application (the traditional way in PhoneGap is to put pages/images/etc. in teh assets/www folder in the Android project), then the app will be able to function offline.

Categories : Android

Powershell : Remote Internet Connection check
One idea that comes in mind is to issue a ping command (from your machine) where the source of the ping is the remote computer and the target could be any valid Internet (ip) address (source http://www.powershellmagazine.com/2012/08/26/pstip-a-hidden-gem-of-the-test-connection-cmdlet/): [bool](Test-Connection -Source RemoteComputer -ComputerName google.com -Count 1 -ErrorAction SilentlyContinue)

Categories : Powershell



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.