ConnectionManager.getActiveNetworkInfo() force closes?

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

ConnectionManager.getActiveNetworkInfo() force closes?

Postby danguyf » Sat Jun 13, 2009 2:12 am

I am attempting to check whether there is a network connection. I couldn't find any sample code, whether because it isn't there or because my google-fu is weak, so I came up with the following:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  3.  
  4. NetworkInfo netInfo = connManager.getActiveNetworkInfo();
  5.  
  6. if ( !netInfo.isConnected() ) {
  7.  
  8. ...
  9.  
  10.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


The second line causes an immediate force close upon running the application.

I am rather new to Eclipse, and debuggers in general, but I didn't see anything that looked relevant when I stepped through it.

Do any answers jump out at anyone? Or does anyone have a suggestion for an alternate method to achieve the same goal?

Thank you.
danguyf
Freshman
Freshman
 
Posts: 6
Joined: Mon Jun 08, 2009 5:49 pm

Top

Postby rednos » Tue Nov 17, 2009 10:43 am

hi.
Did you add this to AndroidManifest.xml?

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
rednos
Freshman
Freshman
 
Posts: 2
Joined: Tue Nov 17, 2009 10:38 am
Location: S.Korea

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 5 guests