Android :: Way To Make HTTP Connection Using GSM Network?
Sep 29, 2010
I need to make HTTP request on Android using GSM connection, not Wifi. My current solution is to disconnect from all wi-fi connections and perform a request. Is there any better solution? I could not find any relevant methods in the API (I looked in package org.apache.http, but it seems it is completely unaware of what type of connection should be used).
View 1 Replies
Mar 6, 2009
I have been looking at the ConnectivityManager class documented at http://developer.android.com/reference/android/net/ConnectivityManage... .
I would like to know if an Android application can open a network connection (socket) on a specified network interface [on a device supporting multiple network interface types WiFi, Cellular, WiMax etc] ? I am looking for the capability for an application to open a socket on a given type of network for example over WiFi network or over 3G Cellular Data network.
If this is possible in Android, how would I code this requirement within the API Framework ? The ConnectivityManager enables an application to learn about available network connections and currently categorises them as either TYPE_WIFI or TYPE_MOBILE.
There is a member function in the ConnectivityManager class called requestRouteToHost(int,int) [url] which "Ensure that a network route exists to deliver traffic to the specified host via the specified network interface. An attempt to add a route that already exists is ignored, but treated as successful." Sounds like this would install an IP routing table entry to reach a given host via a specified network interface type (WiFi or Mobile). After calling this would it be sufficient for an application to open a socket and connect to the desired destination address ?
Or perhaps the application needs to bind() a socket to a local address of a network interface of the desired type (WiFi or Mobile) Or by setting a socket-level socket option of SO_DONTROUTE ?
View 2 Replies
View Related
Jan 18, 2010
I need to send asynchronous calls to the server. During network connection this works fine. How ever if i disable my LAN from Network connections android will through a socket exception after the specified timeout for that particular call. Now the issue that i face is the time out happens in a synchronous manner. Though both the calls has been started in a thread the timeout is not happening at the same time. If i keep the timeout as 20sec i am getting a socket exception for the first call after 20 sec and after the next 20 sec i get the timeout for the next call. Why is this happening..? I am not opening two connections asynchronously in this case. I am attaching a sample code that can replicate the above scenario. Code...
View 9 Replies
View Related
Oct 14, 2010
I'm making an http request. I'm on a platform (android) where network operations often fail because the network connection might not be immediately available. Therefore I'd like to try the same connection N times before completely failing. Was thinking of something like this:
DefaultHttpClient mHttp = ...;
public HttpResponse runHttpRequest(HttpRequestBase httpRequest)
throws IOException
IOException last = null;
for (int attempt = 0; attempt < 3; attempt++) {
try {
HttpResponse response = mHttpClient.execute(httpRequest);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200) {
return response }
} catch (IOException e) {
httpRequest.abort();
last = e;
throw last;
I'm mostly worried about the connection being in some state which is invalid on subsequent retries. In other words, do I need to completely recreate 'httpRequest', should I avoid calling httpRequest.abort() in the catch block, and only call it in the final failure?
View 2 Replies
View Related
Aug 17, 2010
I am using org.apache.http.*; API's to make HTTP Post Connections over Internet from the Android Application. I added the Internet Permissions in the Manifest file and it works fine. Now i want my application to make the same HTTP requests over WiFi network through which the handset is connected.
Do i need to make code changes to achieve this? Do i need to add some permissions? as i am unable to make requests...
View 1 Replies
View Related
Mar 10, 2010
is there a way to force a connection (http) to go over OTA (Over-The- Air) even if you have a wifi connection?
View 3 Replies
View Related
Jul 5, 2010
I am a newbie in android and i had a question whether i should use a service or thread for http connection and what will be the advantage of using a service over a thread or viceversa. Please help me out with this.
View 13 Replies
View Related
Dec 22, 2009
Do you know how to set Content-Type on HttpURLConnection? Following code is on Blackberry and I want the Android equivalent:
connection.setRequestProperty("content-type", "text/plain; charset=utf-8");
connection.setRequestProperty("Host", "192.168.1.36");
connection.setRequestProperty("Expect", "100-continue").
View 4 Replies
View Related
Apr 26, 2009
I have set up proxy in the sdk emulaotor and can access internet via the proxy in the browser. but this does not work for my http connection application, it gives "Unknown host exception" i have used -dns-server option when launch the app.
View 2 Replies
View Related
Sep 6, 2010
I'm facing an annoying problem here. My application is connected to a server that sends some data from time to time. It's some kind of eventing server. In order to receive data, I'm connecting to the server with an HttpURLConnection, retrieve the response InputStream and loop on it with the read method. The connection is always open. The distant server is cutting the connection every 5 minutes (for test purpose). When connection is closed, my application has to reconnect again. We detect a Connection Reset by Peer exception when the server closes the connection. The problem is that most of the time, I never receive the Connection Reset by Peer exception. So my application can't know that is has to reconnect and it's stucked on the read instruction. The InputStream.Read() method shouldn't always raise an exception if the connection is closed? What can I do to always detect Connection Reset by Peer exception?
View 15 Replies
View Related
Dec 21, 2009
I am facing with problem related Http Connection.
MY code...
This code can't download data completely.
For example :
Total size to read : 13901 bytes
Above code can read size : 12937 bytes
What is wrong here?
View 2 Replies
View Related
Aug 26, 2010
How to create an Http Connection to retrieve a web page content to my android? Please post example code for this.
View 1 Replies
View Related
Aug 4, 2009
I want to Download image from Server using Http Connection and at same time i want to show ProgressDialod till is not Downloaded i dont undestand.
View 3 Replies
View Related
Feb 5, 2010
I am trying to create HTTP connection using AsyncTask class.
Is it possible to create HTTP connection ?
Can you suggest sample source code?
View 2 Replies
View Related
Oct 28, 2010
Would this Android code be a correct way to test for http network availability during a phone call, or does it exclude networks that should be included or vice versa:
CODE:.....................
View 1 Replies
View Related
Aug 17, 2010
Is there a way to make an simple HTTP request? I want to request an PHP page / script on one of my website but I don't want to show the webpage. If possible I even want to do it in the background (in an BroadcastReceiver)
View 3 Replies
View Related
Dec 24, 2009
I am trying to make HTTP get & post connections.
Which package is recommended for that?
Is it java.net or org.apache.http?
Does java.net comes included in the sdk?
Any reference/code to connection makin would be appreciable as well.
View 1 Replies
View Related
Aug 11, 2010
I'm new in Java.
I'm trying to do code...
but said
The type Header is not generic; it cannot be parameterized with arguments <NameValuePair>
how I can do it?
View 2 Replies
View Related
Mar 24, 2009
I'd like to make an http request to a remote server while properly handling cookies (eg. storing cookies sent by the server, and sending those cookies when I make subsequent requests). It'd be nice to preserve any and all cookies, but really the only one I care about is the session cookie.
With java.net, it appears that the preferred way to do this is using java.net.CookieHandler (abstract base class) and java.net.CookieManager (concrete implementation). Android has java.net.CookieHandler, but it does not seem to have java.net.CookieManager.
I could code it all by hand by inspecting http headers, but it seems like there must be an easier way.
What is the proper way to make http requests on Android while preserving cookies?
View 3 Replies
View Related
Nov 30, 2011
When I connect to the student's wifi network, it requiers to configure the proxy with authentification. Well I'm fine with that, and the browser works all right, but all of the apps which require internet access aren't working. I also noticed, that when I'm configuring the proxy in the settings, it actually says that the HTTP proxy will be used by the browser, but not by some of the apps (in my case none of the apps work, including the pre-installed apps like android market, youtube or google maps).
So my question is that is there any way to make the apps work with the HTTP proxy? I should say that I found this thread on this forum:
[URL]
but I had trouble understanding it. Also if this matters, I'm using an Asus Eee Pad Transformer running android 3.2.1.
View 9 Replies
View Related
Oct 19, 2010
I have an android application using LocationManager get the cell network location and not the Wifi location? If I have turned off the Wifi antenna and do the following:LocationManager lm = (LocationManager) paramContext.getSystemService(Context.LOCATION_SERVICE);I am always returned the Wifi location and not the cell network location. I want it to return the cell location since I have moved fromthe Wifi location. I tried using a LocationListener but that doesn't seem to help.
View 1 Replies
View Related
Jun 10, 2010
I am developing an Android application and I would like to setup a tcp/ip type of connection between two Android phones using the 3G/Edge network. My test version will establish a connection if I have both phones on a lan using wifi but when I use T-Mobile's network a connection is not established. Could this issue be a port or ip address?
View 12 Replies
View Related
Sep 8, 2010
I'm building an application for my own use, and I like to get connection via mobile network but I don't know how to do that. What I want is the same behaviour that offers severals existent widgets to turn on/off the data connection.
View 2 Replies
View Related
Jul 17, 2009
How to create an HTTP request object of POST type in android? Which class need to be extend or what method need to implement? How to establish connection to a server? Actually i want to connect to a microsoft exchange server, and then i have to send a request to it using HTTP.
View 8 Replies
View Related
May 11, 2009
I'm working on some data transmission program and current it works alright on WIFI connection.
However, I understand that if I am in an environment where there are both 3G and WIFI coverage... the phone will (by default) be turned onto the WIFI network connection.
However, if for some reasons, I wish to be connected directly to 3G (e.g. 3G is more stable in public WIFI area).... is it possible to do so programatically on the Android phone? If i'm not wrong, it's possible using the ConnectionManager API, am I right?
May i ask if anyone has done something like that and don't mind sharing the code snippets to do so , or point me to the right direction for this?
View 2 Replies
View Related
Jul 16, 2010
I wonder if anybody has ran into the issue where a running emulator would lose network connection all at a sudden for no obvious reason. And I am sure the computer running the JVM is still online.Restarting the emulator seems to fix the issue but it's been a major PITA for me as it interrupts the work flow.I am using 2.1 SDK 7.
View 5 Replies
View Related
Aug 20, 2009
I'm running some service on my android emulator. On android I bound it to 127.0.0.1:6100.
How can I access the service from my development machine? Do I have to redirect?
View 8 Replies
View Related
May 10, 2010
How do you detect the network connection type on Android?
Is it through ConnectivityManager.getActiveNetworkInfo().getType(), and the answer is limited to Wifi and mobile?
View 2 Replies
View Related
Sep 13, 2010
I am checking to see if my app has a network connection Whenever I rotate my screen between landscape and portrait this method returns false. It makes me wonder if Network connections are getting killed during the rotation?
View 1 Replies
View Related
Sep 30, 2009
What are the settings required to access network for those who dont have ADSL connection?
View 1 Replies
View Related