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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:14:48+00:00 2026-06-16T01:14:48+00:00

I’m android beginner so please be easy on me. I’m doing some exercises and

  • 0

I’m android beginner so please be easy on me. I’m doing some “exercises” and i’m writing simple app which will tell RSSI strength of home wifi network. Getting that number is pretty easy, but updating it and showing that on screen it’s a little more complicated as i thought.

First this is my onCreate Activity. In this activity i’m launching another android component – Service. Because the code will run in background (i know i could use thread or something else, but this is for “practice” sake, and i have a few ideas what to do with this app, while running service and not interacting with UI )

public class MainActivity extends Activity {
    TextView wifi_check;

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

        referenceViews();

        startService(new Intent(this, CheckingWifiService.class));
        //wifi_check.setText(""+getIntent().getExtras().getInt("RSSI"));
    }

    private void referenceViews() {

        wifi_check = (TextView) findViewById(R.id.wifiCheck_TV);
    }
}

Because my code will run every second or so, i will use TimerTask for this purpose. And here is my TimerTask class, which includes run() method, and code for executing inside

public class TimerTsk extends TimerTask {
    Context act;
    WifiManager wifiMan;
    WifiInfo info;
    Bundle sendInfo;
    Intent intent;
    int rssi;

    public TimerTsk(Context context) {
        act = context;
    }

    @Override
    public void run() {
        intent = new Intent();  
        sendInfo = new Bundle();

        wifiMan = (WifiManager) act.getSystemService(Activity.WIFI_SERVICE);

        info = wifiMan.getConnectionInfo();
        rssi = info.getRssi();
        Log.d("WORKED", "RUNNING SUCESSFULLY");

        // i want to send info to my activity

        sendInfo.putInt("RSSI", rssi);
        intent.putExtras(sendInfo);
    }
}

From this class , i want to send result of RSSI to my activity and then update a text. But when i call this code below, on activity i always get NullPointerException.

wifi_check.setText(""+getIntent().getExtras().getInt("RSSI"));

To be honest i had hard time figuring out which part of code is throwing an exepction. And i found that more exactly, this part of code is throwing an exepction.

getInt(“RSSI”)

Overall i see that service is running, because in my LOGCAT i see a message that i create with Log.d in TimerTsk class.

Any ideas why is this happening?

Here is my service class:

public class CheckingWifiService extends Service{

int rssi;
Timer time;
TimerTsk ttsk;




@Override
public IBinder onBind(Intent intent) {

    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {


time = new Timer();
time.schedule(new TimerTsk(getApplicationContext()), 500);





    return START_STICKY;
}

}

Here is my LogCat:

enter image description here

  • 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-16T01:14:50+00:00Added an answer on June 16, 2026 at 1:14 am

    I see a common mistake. Don’t do this:

    sendInfo.putInt("RSSI", rssi);
    intent.putExtras(sendInfo); // This adds a Bundle to your existing Bundle!
    

    You are creating an Intent, with a Bundle of extras, with a Bundle that holds rssi. Leave out this unnecessary Bundle:

    intent.putExtras("RSSI", rssi);
    

    Now in your next Activity you can use:

    getIntent().getIntExtra("RSSI", 0);
    

    However you should always check to make sure there aren’t any surprise null variables:

    Intent in = getIntent();
    if(in != null) {
        int rssi = in.getIntExtra("RSSI", -1);
        if(rssi < 0)
            wifi_check.setText(""+rssi);
        else
            wifi_check.setText("Unknown");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.