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 8325095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:19:03+00:00 2026-06-09T00:19:03+00:00

I have this code: List<ScanResult> vAll = null; WifiManager vMainWifi = null; @Override public

  • 0

I have this code:

    List<ScanResult> vAll = null;
    WifiManager vMainWifi = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wi_fi);

        vMainWifi = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
        vAll = getWiFi();
    }   
    public void btnViewWiFI_onClick(View v) {
        TextView vTmpTextView = (TextView) findViewById(R.id.tvRetele);
        String vString = "WiFi:";
        List<String> vLista = getWiFiString();
        if (vLista != null) {
            for (int i = 0; i < vLista.size(); i++)
                vString += "\n\t" + vLista.get(i);
        }
        vTmpTextView.setText(vString);
    }
    List<ScanResult> getWiFi() {
        if (vAll != null)
            return vAll;
        if (vMainWifi.isWifiEnabled())
            return vMainWifi.getScanResults();
        else {
            vMainWifi.setWifiEnabled(true);
            return vMainWifi.getScanResults();
        }
    }
    List<String> getWiFiString() {
        List<String> vTmp = null;
        if (vAll == null)
            vAll = getWiFi();
        if (vAll != null) {
            for (int i = 0; i < vAll.size(); i++)
                vTmp.add(vAll.get(i).BSSID + ", " + vAll.get(i).SSID);
        }
        return vTmp;
    }

In layout xml

    <TextView
        android:id="@+id/tvRetele"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="94dp" />

    <Button
        android:id="@+id/btnViewWiFI"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="145dp"
        android:layout_marginTop="233dp"
        android:onClick="btnViewWiFI_onClick"
        android:text="@string/viewWiFi" />

In Manifest file i have this

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

If I try to debug this I get empty list, probably becouse I get error for WiFi Networks, but when I upload to phone and install this application I get crash when I pres the button.
What I do wrong?

  • 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-09T00:19:06+00:00Added an answer on June 9, 2026 at 12:19 am

    You are not instantiating the list vTmp in getWiFiString() ! you get a NullPointerException when trying to add elements to it.

    What you probably need is:

    List<String> vTmp = new ArrayList<String>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
I have this code: public void FileCleanup(List<string>paths) { string regPattern = (@[~#&!%+{}]+); string replacement
I have this code: list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int
Say I have this code - public interface ParentInterface1 { public List<? extends ChildInterface1>
I have this simple code public String toString() { **Iterator it = list.iterator();** String
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int
I have this Code for Reading Excell Records: public IEnumerable<FillinEntity> Map(IEnumerable<ExcelRow> excelRows) { List<FillinEntity>
I have this code, void Generate(List<string> comb, string prefix, string remaining) { int currentDigit
I have this code : public static List<string> MyTable = new List<string>(); dsView =
I have this code: void Main() { List<Employee> employeeList; employeeList = new List<Employee> {

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.