1

I have been reading many different posts on Stack Over Flow on getting the signal strength printed and unfortunately, the ideas were a bit too deep for me. Here is what I tried to do to print something and I'm not getting results. I'm using the emulator for now. Maybe there is a next step I am not aware of. Please, if you have any tips, suggestions, advice, or knowledge on what I am doing wrong and on how to access the signal strength, I will appreciate it. Thanks!

TelephonyManager mFlags;

PhoneStateListener phoneStateListener = new PhoneStateListener() {

        public void onSignalStrengthsChanged (SignalStrength signalStrength)
        {
            super.onSignalStrengthsChanged(signalStrength);
            Log.v("Not", "Printing this part");
            Log.v("Signal Strength Is", String.valueOf(signalStrength.getGsmSignalStrength()));
        }
};

Inside of my OnCreate method:

    mFlags = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);  
    mFlags.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);     

Nothing is working! How do I register the listener? What are the permissions? And finally, why isn't it detecting my listener? The question is still out in the open, and I am as confused as I was in the beginning. I was finding a way to convey my question.

What
  • 73
  • 1
  • 6

1 Answers1

2

Are you registering for signal strength ? If yes, please paste your complete code for debugging.

TelephonyManager mFlags;

    PhoneStateListener phoneStateListener = new PhoneStateListener() {

            public void onSignalStrengthsChanged (SignalStrength signalStrength)
            {
                super.onSignalStrengthsChanged(signalStrength);
                Log.v("Not", "Printing this part");
                Log.v("Signal Strength Is", String.valueOf(signalStrength.getGsmSignalStrength()));
            }
    };

    mFlags = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

    mFlags.listen(phoneStateListener,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); 

http://divandroid.com/android-phonestatelistener-example/

Divya Y
  • 183
  • 1
  • 9
  • And thanks for this extra insight that I need to do that part. And also what do you mean by "single strength"? – What Jan 24 '15 at 23:09
  • 1
    thanks, I corrected it to signal. Please have a look here about using PhoneStateListener http://divandroid.com/android-phonestatelistener-example/ – Divya Y Jan 25 '15 at 18:34
  • The issue I'm facing is that I am not working inside of an activity class and so am not sure on how to apply the code – What Jan 26 '15 at 15:08
  • I am currently using this link for that... but I might face some minor issues still, not too sure of myself. http://stackoverflow.com/questions/4870667/how-can-i-use-getsystemservice-in-a-non-activity-class-locationmanager – What Jan 26 '15 at 15:50
  • Here's what I did so far... I made the listener at the beginning, and the mFlags registration stuff I put into the onCreate method which is how I do not get the syntax errors I put above. However, nothing is being printed..... – What Jan 26 '15 at 17:22
  • How do I register the listener? What are the permissions? And finally, why isn't it detecting my listener? – What Jan 29 '15 at 18:06