Note that there are some explanatory texts on larger screens.

plurals
  1. POSignalStrength in android is not getting displayed
    text
    copied!<p>i have written a simple application to fetch the signal strength in android.... but the signal strength is not getting displayed when i try to display it in the TextView... please let me know what is the problem. (source code is attached below)</p> <pre><code>*public class SignalStrengthActivity extends Activity { private int intSignalStrength; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_signal_strength); ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); //telephonyManager.listen(new MySignalStrengthlistner(), PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); WifiManager wifiManager; if(networkInfo.getType() == ConnectivityManager.TYPE_WIFI){ wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); Toast.makeText(getApplicationContext(), "Signal Strength Wifi: "+wifiManager.getConnectionInfo().getLinkSpeed(), Toast.LENGTH_LONG).show(); //networkDetailsVO.setSignalStrength(wifiManager.getConnectionInfo().getLinkSpeed()); }else if(networkInfo.getType() == ConnectivityManager.TYPE_MOBILE){ telephonyManager.listen(new MySignalStrengthlistner(), PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } TextView textView = (TextView) findViewById(R.id.signalStrength); //Toast.makeText(getApplicationContext(), "Signal Strength Mobile: "+intSignalStrength, Toast.LENGTH_LONG).show(); textView.setText(intSignalStrength); } private class MySignalStrengthlistner extends PhoneStateListener{ @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); //Toast.makeText(getApplicationContext(), "Signal Strength Mobile: "+signalStrength.getGsmSignalStrength(), Toast.LENGTH_LONG).show(); intSignalStrength = signalStrength.getGsmSignalStrength(); } } }* *&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pervazive.fetchsignalstrength" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;!-- &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt; --&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.fetchsignalstrength.SignalStrengthActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:theme="@style/FullscreenTheme" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt;* </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload