title: Get Signal Strength in Android
body: <p>I want to get the Signal Strength of the Device at the point I hit the API call. I have searched on all the related threads and I am not successful yet.</p>
  
  <p>So I would like to get the signal strength like</p>
  
  <pre><code>SignalStrength ss = null  ; // some initialization
  
  int n = ss.getGsmSignalStrength();
  </code></pre>
  
  <p>But while using this, it is obvious that I will get null pointer exception since I have initialised <code>SignalStrength</code> as null. But I don't know how to initialise this.</p>
  
  <p>Also that I don't want to use <code>PhoneStateListener</code> because it is triggered only if the signal changes.</p>
  
  <p>I am getting the Signal Strength using the below code</p>
  
  <pre><code>TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
  CellInfoGsm cellinfogsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0);
  CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
  cellSignalStrengthGsm.getDbm();
  </code></pre>
  
  <p>But I don't want to use <code>CellSignalStrength</code> because it is only added in API Level 17 and will not work under 17. I want the code to work on API Level 7+.</p>
  
  <p>Or is there any other method, so that I could get the signal strength at the point of hitting the API call?</p>