0

I am getting several errors and can't discover which is causing the problem.

Errors:

  • Cannot resolve symbol
  • Unexpected Token (while loop)
  • Unknown class "x"

How can I set the textView to display the wifiSignal strength?

Sorry for not narrowing down the problem more, but I am new to developing in android studio and am too lost to be specific.

Thanks so much for any help you can provide!

Code:

package com.example.a18lts01.wificompass;

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    } }

    class wifi
    {
        @Override
        public void run() {

        }

        int x = 1;
        while(x == 1)
        {
            int signalLevel = result.level;
            TextView.setText(signalLevel + "db");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            Thread myThread = new Thread(myRunnable);
            myThread.start();
        }
    }
}
hooknc
  • 4,854
  • 5
  • 31
  • 60
  • What is `result` variable? Why code starting from `int x= 1...` isn't in any method? It looks like just no matching braces... And next time you post code here use CTRL + ALT + L in android studio... – J K Mar 21 '18 at 21:01
  • While editing your code, I noticed that your while loop was messed up. In the while loop you had x = 1 which would assign x to be 1 instead of checking to see if x == 1. – hooknc Mar 21 '18 at 22:10

1 Answers1

0

Looks like you've got some misplaced brackets. I'm assuming you want your int x = 1; etc. to be inside the run() method? Currently you have an empty run() method.

Double-check the placement of the brackets. It looks like you need to remove the } a couple of lines after public void run() {, and add a } at the end of the wifi class.

avojak
  • 2,342
  • 2
  • 26
  • 32