title: Getting GPS strength in Android
body: <p>In my app, I have to find out GPS strength. However, when I use the following code, I get 0 only for count no of satellites. So, I could not get GPS strength.</p>
  <p>My code:</p>
  <pre><code>public void onCreate(Bundle savedInstanceState) {
    locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    locMgr.addGpsStatusListener(onGpsStatusChange) ;
    onGpsStatusChange.onGpsStatusChanged(GpsStatus.GPS_EVENT_SATELLITE_STATUS);                     
   // Listener for GPS Status...
  }
  
              final Listener onGpsStatusChange=new GpsStatus.Listener()
              {       
                      public void onGpsStatusChanged(int event)
                      {
                          Log.e(&quot;gps&quot;,&quot;in class&quot;);
                              switch(event)
                              {
                               case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
                                    GpsStatus xGpsStatus =locMgr.getGpsStatus(null) ;
  
                                    Iterable&lt;GpsSatellite&gt; iSatellites               =xGpsStatus.getSatellites();
                                    Iterator&lt;GpsSatellite&gt; it = iSatellites.iterator();
                                     int count=0;
                                     while(it.hasNext()){
                                      count=count+1;
                                          GpsSatellite oSat = (GpsSatellite) it.next();
                                          
  
                                          Log.e(&quot;gps&quot;,&quot;&quot;+oSat.getSnr());   
                                     }
                                   Log.e(&quot;count&quot;,&quot;&quot;+count);
                                   tv1.setText(&quot;&quot;+count);
                               break;
                              }
                      }
              };
  </code></pre>