android-internet

How do I display no internet connection popup and an html page when internet is not available for webview?

二次信任 提交于 2019-12-31 03:50:30
问题 I am using webviews in my app and want to make sure when internet is not available the pop up message displays for no internet connection and also displays an html page in the background saying internet connection required. I have added some code for checking internet connection, but its not working/ showing errors for checkmark(code added based on online research). Any clue how to fix the same? Here's the code below: public void onCreate(Bundle savedInstanceState){ super.onCreate

How to set connection timeout for JSONParser.makeHttpRequest in Android?

别来无恙 提交于 2019-12-30 15:42:04
问题 I am getting and posting some data with JSONParser.makeHttpRequest . When the connection is slow it takes a while to get a response and I would like to set the timeout limit to 5 seconds. I found this post showing how to set HttpResponse timeout but couldn't integrate it with JSONParser. Here is the code I use for HttpRequest JSONParser jParser = new JSONParser(); List<NameValuePair> params = new ArrayList<NameValuePair>(); JSONObject json = jParser.makeHttpRequest(url, "GET", params); I will

How to set connection timeout for JSONParser.makeHttpRequest in Android?

不羁岁月 提交于 2019-12-30 15:41:17
问题 I am getting and posting some data with JSONParser.makeHttpRequest . When the connection is slow it takes a while to get a response and I would like to set the timeout limit to 5 seconds. I found this post showing how to set HttpResponse timeout but couldn't integrate it with JSONParser. Here is the code I use for HttpRequest JSONParser jParser = new JSONParser(); List<NameValuePair> params = new ArrayList<NameValuePair>(); JSONObject json = jParser.makeHttpRequest(url, "GET", params); I will

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

馋奶兔 提交于 2019-12-30 01:03:46
问题 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.

Checking Internet connection in Android

耗尽温柔 提交于 2019-12-29 02:00:11
问题 Is there any background task which runs with in application to check for internet connectivity for below scenarios as common ? 1.Start of parsing/fetching data from server 2.In between of parsing/fetching from server Any sample code or links helps me a lot. 回答1: You can start an IntentService or Service and use this: public boolean CheckInternet() { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo wifi = connec

No internet access in signed APK

杀马特。学长 韩版系。学妹 提交于 2019-12-25 04:45:42
问题 I was working on an app that was working fine in the Debug build version and then I created a signed APK using keystore , and then with Android Studio --> Generate SIgned APK. When I install the signed APK manually by downloading on to my phone, it asks for all permissions including internet access. However post installation, app starts but none of the server calls / API calls are working. The phone has internet connection though (webpages open up in browser) My android manifest is : <?xml

Android: Check internet connection - returns true (incorrectly)

别来无恙 提交于 2019-12-24 13:03:32
问题 To check for internet connectivity, i am using this code: public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); //return netInfo != null && netInfo.isConnectedOrConnecting(); return netInfo != null && netInfo.isAvailable() && netInfo.isConnected(); } This is the most commonly used code i found everywhere - however it is not working reliably. This is returning true, although i

How to determine the network unavailability in android

旧城冷巷雨未停 提交于 2019-12-23 05:25:58
问题 I want to show alert that connection not available in my android application. I am calling some rest request in my application. To check this network unavailability scenario I manually disconnect my wifi in my laptop (I am testing in simulator) . Code where I call service is here resp = client.execute(httpPostRequest); and here I am catching exception catch (IllegalStateException e) { //assertTrue(e.getLocalizedMessage(), false); e.printStackTrace(); } catch (ClientProtocolException e) { /

Effective way to check for slow internet connection and differentiate between network connection and actual internet connection in android

只愿长相守 提交于 2019-12-23 01:13:17
问题 How to check if the device is connected to internet or it is just connected to external wifi network? Because NetworkInfo returns true if a device is connected to an external wifi network even there is no network connection. When device is connected to wifi but there is no internet access,my app's network connectivity-check class returns true but application crashes with the exception that it cannot access the corresponding http url. 回答1: If you want to know when you have an active internet

ask user to connect to internet or quit app (android)

被刻印的时光 ゝ 提交于 2019-12-21 12:15:22
问题 i am working on an image gallery app, in which application is retrieving images from internet. so i want to prompt a dialog-box to ask user to connect to internet or quit application. show user both WiFi and Carrier network option. 回答1: this checks for both wifi and mobile data..run tis code on splash or your main activity to check network connection.popup the dialog if the net is not connected and finish the activity.It's that simple private boolean haveNetworkConnection() { boolean