Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
LinkBack Thread Tools
Old February 2nd, 2012, 04:09 AM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Feb 2012
Location: Indore
Gender: Male
Posts: 8
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to zalani
Default check Internet connectivity

public boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
// test for connection
if (cm.getActiveNetworkInfo() != null&& cm.getActiveNetworkInfo().isAvailable()&& cm.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;

// permission used
<uses-permission android:name="android.permission.INTERNET"/>

zalani is offline  
Reply With Quote
sponsored links
Old December 5th, 2012, 07:13 PM   #2 (permalink)
New Member
Join Date: Feb 2011
Posts: 4
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts

Is there an app that can check internet connectivity and give a notification in the status bar if internet connectivity is lost?
LB2064 is offline  
Reply With Quote
Old December 7th, 2012, 01:58 PM   #3 (permalink)
Senior Member
jonbonazza's Avatar
Join Date: Jul 2010
Gender: Male
Posts: 1,936
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts

I think you are going about this the wrong way. What you need to do is register a BroadcastReciever that listens for a network connectivity change event. Inside your receiver, you should handle the state change depending on whether or network was enabled or disabled. You can even find out what kind of network the event was generated for (i.e. mobile or wifi).
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
jonbonazza is offline  
Reply With Quote

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 01:00 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.