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

  • Home
  • SEARCH
  • 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 8002469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:22:37+00:00 2026-06-04T16:22:37+00:00

This code is giving an error saying error receiving broadcast intent in activity I

  • 0

This code is giving an error saying “error receiving broadcast intent in activity”
I cant find any eroors though………..any ideas ?
i’ve added the loop condition as seven as i only want the first seven scan results

class WifiReceiver extends BroadcastReceiver {
    public void onReceive(Context con, Intent intent) {
        sb = new StringBuilder();
        wifiList = mainWifi.getScanResults();

        for(int i = 0; i < wifiList.size(); i++)
        {
            sb.append((wifiList.get(i)).SSID.toString());
            sb.append(' ');
            sb.append('!');
            sb.append("\n\n");
        }

        String net = sb.toString();

        if(wifiList.size() > 0)
        {


        char excl = '!';
        int excl1 = excl;
        String[] aray = null;
        for(int j = 0; j<7; j++)
        {
            int index = net.indexOf(excl1);
            String a = net.substring(0, index);
            aray[j] = a;
            String temp = net.substring(index+1);
            net = temp;

        }

        String one = aray[0];
        String two = aray[1];
        String three = aray[2];
        String four = aray[3];
        String five = aray[4];
        String six = aray[5];
        String seven = aray[7];
        tv1.setText(one);

    }
        else
        {
            tv1.setText("No Networks Detected");
        }
}
}

PS : I’ve only added into one TextView as this is a test module

  • 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-06-04T16:22:38+00:00Added an answer on June 4, 2026 at 4:22 pm

    The “aray” array is not being intialized correctly. You need to initialize “aray” before accessing it:

    String[] aray = new String[7];
    

    You are also going outside the dimensions of the array. this:

    String seven = aray[7];
    

    should be:

    String seven = aray[6];
    

    An even better solution would be to use an ArrayList.

    ArrayList al = new ArrayList();
    al.add(yourString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what's wrong with this code? It's giving me an error
This my code, and it is giving me an unexpected $end error and I
I cannot understand why the code below is giving me this error in firebug
This code is giving me this error: The object cannot be deleted because it
My fsyacc code is giving a compiler error saying a variable is not found,
this code is giving me error: error in converting datatype nvarchar to bigint this
In this sample code StartActivity is giving error, if i use this in another
I've simplified my JavaScript code to the example below; this code is giving me
I have this piece of code that is giving me trouble. I know all
This is my code in which every line is giving me an invalid context

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.