How to get information about the satellites from android?

后端 未结 3 504
粉色の甜心
粉色の甜心 2021-02-10 21:12


I am trying to get the satellite information from the android and wrote this following code which is not giving any results, could any one point out why is it so?

3条回答
  •  走了就别回头了
    2021-02-10 21:44

    Try this:

     LocationManager locmgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
         //locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10L, 5.0f, this);
         Location location = locmgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    
         if ( location == null ) {
             location = locmgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    
         }
         if ( location == null ) {
             location = locmgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
    
         }
    

    Let me know if any issue.

提交回复
热议问题