Click here to Skip to main content
15,941,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Updated 26-Mar-12 21:25pm
Manfred Rudolf 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

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

Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900