Click here to Skip to main content
11,705,098 members (46,699 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Android
I am trying to get the signal strength info from the all the available wifi access points but it doesnt work... Its always returning some null exception it seems. I tried to run it in mobile also but its not working. I have pointed out the line which is creating error by placing a comment in bold.

package a.c;
import java.util.ArrayList; 
import java.util.List;
import a.c.WifiActivity.WifiReceiver; 
import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.content.IntentFilter; 
import android.os.Bundle; 
import android.widget.TextView; 
import android.widget.Toast; 
public class WifiActivity extends Activity { 
private WifiManager mainWifi; 
private WifiReceiver receiverWifi;
TextView sig;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) { 
mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); 
receiverWifi = new WifiReceiver(); 
registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); 
class WifiReceiver extends BroadcastReceiver { 
public void onReceive(Context c, Intent intent) { 
List wifiList = mainWifi.getScanResults(); 
for (int i = 0; i < wifiList.size(); i++) { 
ScanResult scanResult = wifiList.get(i); 
// I have to put a try catch block here otherwise it returns an exception. 
catch(exception e){}

Can anyone help me with the code. I dont know what to do to get the signal strength info from the access points.There are access points nearby but im not able get the strength.If anyone could provide the code or any help then i would be thankful. Note: I have added the required permission to access wifistate in the manifest also so its not a problem there.
Posted 26-Mar-12 21:22pm
Edited 26-Mar-12 21:25pm
Manfred R. Bihy at 27-Mar-12 4:21am
I just want to let you know that telling us what exception is occurring and what the message is would be of tremendous help to us in unraveling this mystery.
prajnavantha at 27-Mar-12 12:48pm
Its actually a null pointer exception.....

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I don't have any solution but i learned a lot of things here and it really works.. it helps a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 595
1 OriginalGriff 289
2 Andy Lanng 175
3 CPallini 162
4 ppolymorphe 126
0 OriginalGriff 8,958
1 Sergey Alexandrovich Kryukov 8,276
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 2 Apr 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100