Android :: Detect Network Connection Type On Droid?
May 10, 2010How do you detect the network connection type on Android?
Is it through ConnectivityManager.getActiveNetworkInfo().getType(), and the answer is limited to Wifi and mobile?

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?
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 ?
The most important things i want to know are the device type, the os version, if it has a hardware keyboard and maybe the screen resolution. but if you know other useful debug information.
View 2 Replies View RelatedDoes anyone know if I activate the Wifi connection it trumps the carrier network connection? In other words, if the Wifi connection is active (assuming i have a signal) and my carrier signal is also active, and I want to stream some audio--which pipe does the phone use to bring in the audio?
View 11 Replies View RelatedIn my application I need sometimes send data via http (using HttpClient, HttpGet and HttpPost). Can I choose (from source code) connection which is used? For example, I'd like to use only gprs, not wifi, not bluetooth. Or only wifi, not gprs.
View 5 Replies View RelatedIm wondering if this is an issue with my phone or an issue with the network in my area. Basically, i try to turn on my mobile network and it freezes at "turning on" i hit the back arrow, head back in and it says that the connection failed or "standby for connecting to the mobile network.The only thing different i have done today is install spare parts, and read a few issues people had with sense turning off, and wondered if maybe something within it is bugging my phone, just a thought though.
View 14 Replies View RelatedI did a search and couldn't really find any threads with people having similar issues. I saw that people were having trouble keeping their X connected to a network, but that's not my issue.
I have a Droid Incredible and added a line to get the X figuring I'd just sell off the Inc when my X arrived. Since I got my X, I've noticed that when I am connected to a wifi network, it almost seems to crawl when I hop around from page to page.
I ran some speed tests on my internet connection, it seemed that it was my phone. So then I ran speed tests with the app in the marketplace, first on the DInc and then on X. The upload speeds were pretty close to identical, but the download speeds were consistently 300 kbps higher on the Droid Incredible.
So after running those tests, I decided to just do some side by side browsing on the X and Inc to see how big the difference was between the two. I opened up a few pages that I don't ever really visit so they weren't in my browsing history and the Incredible would again open pages 10-15 seconds quicker.
Has anyone else had these same issues? I know their was a software release shortly after the initial launch, is their another one in the pipeline?
I love the phone, it's a multimedia beast. But I don't think I want to keep one that has a busted wifi connection.
I don't want my app to crash if the user doesn't have wifi or 3g connectivity. How can I catch this at runtime in my app?
View 1 Replies View RelatedDo 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").
BB user here and the only thing holding me back from getting an Android is the fear of going over my 200MB limit on data.
I want to use my Android over 3G for emails and calendar sync. Everything else through WiFi because I am constantly connected to WiFi through my campus/home/work. Only need email on the go.
Is there a program that can control what type of data other apps use?
For instance:
Email: 3G (WiFi Preferred)
Calendar Sync: 3G (WiFi Preferred)
Contact Sync: 3G (WiFi Preferred)
Browser: WiFi Only
YouTube: Wifi Only
Or along these lines.
Does anyone have any app that comes to mind?
How can we know the current connection type (ex. Wifi, 3G, 2G...) programmatically?
View 1 Replies View RelatedIn 1.5, I find an icon in status bar to indicate current network type (2G or 3G). Would you please tell me which app sets this icon in status bar? I'd like to go through the source code.
View 2 Replies View RelatedIve been trying to retrieve the current network type, but no success when i say network type: i refer to know this info:
if the type is: NETWORK_TYPE_IDEN or NETWORK_TYPE_UMTS.. and so on. i tried to use: NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();NetworkInfo bonneting = connectivity Manager.getNetworkInfo i am doing this coz i wanna know if the current network is IDEN, or if the current network is connected through wifi any other suggestions will be welcome.
I'm new to the smart-phone & recently picked up the HTC Aria & I can't get it to connect to any type of secure connection WEP/WPA, (Motorola SBG900 Wireless Gateway) I can connect to it unsecured with no problem!? I have searched online & have come up w/no answers..
View 3 Replies View Relatedcan one of you guys type *#*#4636#*#* and let me know what the default is for preferred network type? i changed this to try and get better battery life but it seems nobody on other networks are getting my MMS messages.
View 5 Replies View RelatedI am using u8150 ideos, My Wi-fi or Wifi portable hotspot has just stopped working no matter how much i wipe data factory reset install stock rom or change any rom it doesnt work. First it used to give Error in between connection now it doesnt even get On. it says Error below Wi-Fi doesnt detect any network there is 1 mine and 2-3 in the area that it used to detect, i installed CM7 rom on my mob once and it had many bugs and a kernel too am sure its a kernel or some problem ..
I also deleted a wifi folder from root explorer thinking it will remake itself but delete or not the wifi doesnt work.
I would like to have the cell network type displayed while I am connected to WiFi in the status bar signal cluster. Currently, once you connect to WiFi, the LTE, H, E, etc, go away; I'd like them to stay.
I can move the WiFi icon over to make room for the type icon (LTE, H, E, etc) just by deleting "android:layout_marginRight="-6.0dip"" at the end of the "id/wifi_combo" line in res/layout/signal_cluster_view.xml in SystemUI.apk.
Where is the function that turns off that cell type icon when WiFi is connected in SystemUI.apk? I know the system can detect the type of network whilst WiFi is connected, it's just a matter for forcing that icon to stay displayed.
I am trying this on Cyanogenmod 11.
I just got my new xperia x10 mini and I tried to search my adhoc security enabled WiFi network, but unfortunately the phone didn't find it. Anyone got any idea what the problem can be?
View 3 Replies View RelatedWhenever I type online whether its attempting to compose a myspace response or a general response on a message board like this, I experience annoying lag. I'm sure I'm not the only one, at least I hope I'm not, and I'm pretty sure it wasn't like that in the beginning. My question is, is this a network type thing? Or is it a memory/space type thing. I'm 90% on the wifi, and I would hope its a network thing because the lag online is becoming really annoying.
View 13 Replies View RelatedI 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 RelatedI'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 RelatedI 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 View RelatedI'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?
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 RelatedI'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?
I'm writing an application for android. My problem is that I want it to force the connection in GPRS and not use wi fi. I have a solution like below, but this causes the crash of the application at start.
CODE:..............
I also added the below setting lines into manifest file.
CODE:................
Does anyone know the problem, or an answer to set connection type?
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 RelatedWhat are the settings required to access network for those who dont have ADSL connection?
View 1 Replies View RelatedI am having this error since last two weeks "Your SIM does not allow connection to this network." I have tried everything to the best of my knowledge:
- Reset Phone (Soft & Factory Settings both)
- Rooted Phone
- AnyCut application to reset Radio
- Updated radio to 63.18.55.06JU_6.35.09.26-signed
I want to check that the network connection is alive on the phone from program but when i try to run this code
Code:
private boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
return false;
}
I get the message "Sorry 'Appname' is stopped unexpectedly. Try again".I might have to search the solution elsewhere, i added permissions for network, run the application and got the same error but when i tried to start it from the menu it said application not installed.