detecting network connections

by Faber Fedor » Mon, 02 Mar 2009 10:31:37 GMT


Sponsored Links
 I gave a presentation last week on my Android app and when I pushed the
Magic Button, nothing happened.  On my way home, I realized that I had
neglected to connect to the local WiFi. So, to avoid that ind of
embarrassment again  I need to detect whether or not I currently have a
network connection.  If I don't, I'd like my program to offer a list of
available network connections to choose from.

This can probably be done using the system services, but I can't find the
magic Google phrase that will show me how.

Any suggestions?

-- 

Faber Fedor
Linux New Jersey
 http://linuxnj.com 
faberfedor.blogspot.com

--~--~---------~--~----~------------~-------~--~----~



detecting network connections

by Mark Murphy » Mon, 02 Mar 2009 10:42:48 GMT


 


The android.net package is probably your friend, at least for the first
part.

ConnectivityManager#getActiveNetworkInfo() returns a NetworkInfo.
NetworkInfo#getState() will tell you if you are CONNECTED.

On the second part, I'd find the Intent that launches the wireless
settings activity and just use that.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


detecting network connections

by Faber Fedor » Mon, 02 Mar 2009 12:15:03 GMT


 




Sweet! (I've got to look up what # means in Java.)




That's what I was thinking.  How do I find that Intent?

BTW, I used Droidex to show off my app.  It worked very well, although the
audience wasn't all that impressed; they didn't realize how cool Droidex is
(they are a Cloud Computing (read: non-Android) group).  I expect the next
group (the NYC Android Developer's Group) to be duly impressed.  I'll let
you know. :-)


-- 

Faber Fedor
Linux New Jersey
 http://linuxnj.com 
faberfedor.blogspot.com

--~--~---------~--~----~------------~-------~--~----~



detecting network connections

by Mark Murphy » Mon, 02 Mar 2009 21:40:24 GMT


 


Sorry -- instance method.


*shrug*

Maybe look at the source code to AnyCut. I have a desktop icon for the
wireless settings activity through it, so maybe it has that baked in
somewhere.


Glad to hear it worked!

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. RoboGuice

I'm using RoboGuice, for a few days now, and so far I like it. Does
anyone else use RoboGuice?

http://code.google.com/p/roboguice/

-- 

2. Boss kita mejeng

"Document conversion failed" euy, kaga bisa dibuka attachmentnya...
-----Original Message-----
From: lucky sebastian <9b.andr...@gmail.com>
Date: Wed, 3 Mar 2010 08:49:55 
To: Android<id-android@googlegroups.com>
Subject: [id-android] Boss kita mejeng

Boss kita yg br jalan2 ke spore dan dapet necus gratis, mejeng ganteng di
kompas :-)

Salam,

Lucky Sebastian
@ google n1

-- 
"Indonesian Android Community [id-android]" 

3. Salam dari member baru

4. how to market your android app

5. Apple vs HTC !

6. What is the main differences between android sdk 1.5 and android sdk 2.0

7. Pada dimana yah?