android-internet

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

这一生的挚爱 提交于 2019-12-01 13:50:38
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 be grateful if I can get a code snippet or a link to another post somewhere else. MeNa You can use

How to Set Tag to the request and get it from Response Volley asynchronous request?

你离开我真会死。 提交于 2019-12-01 12:34:25
I have an Android application with multiple REST Api's. The API's are managed using the Volley library. The response is getting and it's woking fine. But when I make asynchronous requests, I can't identify the response of each request. My request method is this: private void httpCall(String URL, String json, String session key, int type) { try { SSLContext sslcontext = SSLContext.getInstance("TLSv1"); sslcontext.init(null, null, null); SSLSocketFactory NoSSLv3Factory = new NoSSLv3SocketFactory(sslcontext.getSocketFactory()); HttpsURLConnection.setDefaultSSLSocketFactory(NoSSLv3Factory); Log.i

Check Network and Internet Connection - Android

谁都会走 提交于 2019-12-01 02:09:02
问题 I was wondering if the method below check that I am both connected to a network, and can actually connected to the internet as well. Not just connected to a network that won't let me access the internet ? public boolean isNetworkAvailable() { ConnectivityManager manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); boolean isAvailable = false; if (networkInfo != null && networkInfo.isConnected()) { isAvailable

Can't get HttpParams working with Postrequest

别来无恙 提交于 2019-11-30 17:31:09
I can't get the HttpParams-stuff from the Android-API working. I just wan't to send some simple Parameters with my Postrequest. Everything is working fine, except for the parameters. The code to set the parameters to the postrequest: HttpParams params = new BasicHttpParams(); params.setParameter("password", "secret"); params.setParameter("name", "testuser"); postRequest.setParams(params); It seems that this code isn't adding any parameter at all, as the server always answer, that my request is missing the "name"-parameter. An example of what is actually working as expected: ArrayList

Can't get HttpParams working with Postrequest

霸气de小男生 提交于 2019-11-30 16:40:08
问题 I can't get the HttpParams-stuff from the Android-API working. I just wan't to send some simple Parameters with my Postrequest. Everything is working fine, except for the parameters. The code to set the parameters to the postrequest: HttpParams params = new BasicHttpParams(); params.setParameter("password", "secret"); params.setParameter("name", "testuser"); postRequest.setParams(params); It seems that this code isn't adding any parameter at all, as the server always answer, that my request

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

Android - Programmatically check internet connection and display dialog if notConnected

*爱你&永不变心* 提交于 2019-11-28 23:06:13
I am working on a live project. and when user click on the app. the welcome screen appears(there is a webview on that screen). and if the internet is not connected then the app crashes. Basically, my problem is to check programmatically that is mobile is connected to internet or not. if not then don't fetch the data from webservice into webview and display a dialog box showing "Check your internet connection" while doing research i found many things, and i have tried to implement that. but, its not satisfying my requirement my code is, public boolean isOnline() { ConnectivityManager cm =

Download Images From URL to SD Card

倾然丶 夕夏残阳落幕 提交于 2019-11-28 20:57:41
I am trying to create a very simple Image Downloading app. in which i want to download all images from this url to sd card: https://www.dropbox.com/sh/5be3kgehyg8uzh2/AAA-jYcy_21nLBwnZQ3TBFAea this code works to load image in imageview: package com.example.imagedownloadsample; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

How to forget a wireless network in android programmatically?

落爺英雄遲暮 提交于 2019-11-28 17:54:30
I am working on an app which wifi , where user will be asked to enter password for the scanned network he selects, if user enters a correct password, it connects and works well. But when user enters wrong password, a new network is added with that name, and will be failing to authenticate cos of wrong password, and it will be having authentication problem status. Now if user tries to again scan and select the same network, and enters correct password, it fails to connect even though password now is correct and will have disabled status, since the previous connection is still showing that

@font-face declarations don't work in Android 4.3 Internet browser?

♀尐吖头ヾ 提交于 2019-11-28 17:37:29
My Samsung Galaxy S3 phone recently upgraded from Android 4.1.3 to Android 4.3. Now several websites I designed which I tested in the Android internet browser are not displaying fonts I have declared with @font-face . What do I need to do to fix this? One of the sites (development version): http://beta.kdfansite.com Here is some of the related CSS for Open Sans: @font-face { font-family: 'OpenSansSemibold'; src: url('http://beta.kdfansite.com/wp-content/themes/scrollider/scrollider/webfonts/Open-Sans/OpenSans-Semibold-webfont.eot'); src: url('http://beta.kdfansite.com/wp-content/themes