Sie sind auf Seite 1von 4

Stack Overflow

Questions

Tags

Users

sign up
Badges

Unanswered

log in

Ask

Read this post in our app!

Problems with saving Signal Strength of current cell in android


0

android

listener

telephonymanager

rssi

signal-strength

I'm trying to get the get the signal strength of the current cell that I'm connected to. So far, I've
found this example:
http://www.android10.org/index.php/forums/44-maplocation/868-tutorialget-gsm-signal
But that is only to get a Toast when the signal is changed. Is there any way to save the value of
the signal strength in a variable?
I tried this with the following code, by saving the value on a variable and getting it, but I keep
getting the "initial value". Here's the code:
package org.mode.gsm;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.widget.TextView;
import android.widget.Toast;
public class GetGsmSignalStrength extends Activity {
TelephonyManager Tel;
MyPhoneStateListener MyListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView abcd = new TextView(this);
abcd.setText(getRSSI());

And the manifest:

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mode.gsm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".GetGsmSignalStrength" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />

I would really appreciate it if anyone could help me save the value of the Signal Strength, or
suggest any other way to do it...
Thanks

share

improve this question


modellero
88 2

Mr_and_Mrs_D
8,189 9 60

Asked
Mar 3 '12 at 18:41

3 13

141

Edited
Jul 8 '13 at 22:47

Where do you want to save the signal strength to? File on an SD card, network, local database? qdot Mar 3
'12 at 18:43
first, I just want to save it in a variable, that I'll put on a database later, but that's not a problem... I just want to
be able to get it from my GetGsmSignalStrength class modellero Mar 3 '12 at 18:58

add a comment

1 Answer

order by votes

GetRssi listener = new GetRssi();


protected int Rssi;
Rssi = 99;
private class GetRssi extends PhoneStateListener
{
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
super.onSignalStrengthsChanged(signalStrength);
Rssi = signalStrength.getGsmSignalStrength();
}
}

Rssi was declared in interger; So after you can create a function (String) which return
""+Rssi like that
public String getRssi(){
return ""+Rssi;
}

You have to convert the value in dBm. Hope that will help!!!

share

improve this answer


13KZ
370

2 8 31

Your Answer

log in

or
Name

Answered
Apr 20 '12 at 14:33

Email

By posting your answer, you agree to the privacy policy and terms of service.

meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc

Post Your Answer

Das könnte Ihnen auch gefallen