Click here to Skip to main content
13,046,087 members (64,969 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 26-Mar-12 21:25pm
Manfred R. Bihy 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 2 Apr 2012
Copyright © CodeProject, 1999-2017
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