Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:24:44+00:00 2026-05-25T12:24:44+00:00

I have 2 different files that need to initiale the same broadcast receiver. I

  • 0

I have 2 different files that need to initiale the same broadcast receiver. I am having problems with retrieving the results. Somehow I’m getting null values on occasion which is a result of not being able to properly reference the class that initiated the scan.

Here is a code example.

public void Connection_Logic (Context c)

    IntentFilter wififilter; 
    wififilter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); 
    public WifiManager wifiManager;
    wifireceiver = serviceConsume.wifireceiver;
    c.registerReceiver(wifireceiver, wififilter);
    wifiManager.startScan();
}

public class serviceConsume {
    public WifiManager wifiMan;
    wifiMan = (WifiManager)getBaseContext().getSystemService(Context.WIFI_SERVICE);
    public BroadcastReceiver wifireceiver = new Wifi_Broadcast(this);
    IntentFilter wififilter; 
    wififilter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); 
    registerReceiver(wifireceiver, wififilter);
    wifiMan.startScan();
}

public class Wifi_Broadcast extends BroadcastReceiver {

    public ServiceConsume main;
    public Connection_Logic ConnLog;

    public Wifi_Broadcast(ServiceConsume main) {
        super();
        this.main = main;
    }

    public Wifi_Broadcast(Connection_Logic ConnLog) {
        super();
        this.ConnLog = ConnLog;
    }

    @Override
    public void onReceive(Context c, Intent intent) {

        if(main != null) {
            List<ScanResults> results = ConnLog.wifiManager.getScanResults();
        } else if (ConnLog != null) {
            List<ScanResults> results = ConnLog.wifiMan.getScanResults();
        }
    }
}

Does anyone have any ideas, why I might be getting null values for results? Am I doing this wrong? If anyone has a code example of this working, it’d be appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:24:45+00:00Added an answer on May 25, 2026 at 12:24 pm
    if(main != null) {
                List<ScanResults> results = ConnLog.wifiManager.getScanResults();
            } else if (ConnLog != null) {
                List<ScanResults> results = main.wifiMan.getScanResults();
            }
    

    in your else if you use main, but main is null.. Maybe it need to look like this:

       if(main != null) {
                    List<ScanResults> results = main.wifiMan.getScanResults();   
                } else if (ConnLog != null) {
                    List<ScanResults> results = ConnLog.wifiManager.getScanResults();
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of different xml files that I need to edit from
I have many, (15-20) different XML files that I need to load to VB.Net.
I have two different modules that need access to a single file (One will
I have several files that are in several different languages. I thought they were
For instance, you have an application which processes files that are sent by different
I have a source directory that includes a mix of different languages and files.
Apparently I can't move files on different volumes using Directory.Move. I have read that
I have a few different OBJ files that I am able to parse and
I have local html files that I need to know how they look like
I have two tab delimited csv files (with headers) that I need to merge

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.