gpt4 book ai didi

android - 我可以在 android 中获取卫星名称吗?它在他们的 SNR、PNR、仰角、方位角中显示了我,但我不知道它显示给我的数据是否正确

转载 作者:行者123 更新时间:2023-11-29 02:10:38 25 4
gpt4 key购买 nike

  package my.pack;

import java.util.Iterator;

import android.app.Activity;
import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.GpsStatus.NmeaListener;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class SatellitesActivity extends Activity {
LocationManager locMgr;
double lat;
double lon;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
MyGpsListener listener = new MyGpsListener();
MyLocationListener locListener = new MyLocationListener();
locMgr.addGpsStatusListener(listener);
locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
locMgr.addNmeaListener(new NmeaListener() {

@Override
public void onNmeaReceived(long timestamp, String nmea) {
// TODO Auto-generated method stub
Log.e("Test!", nmea);
}
});

}



public class MyGpsListener implements GpsStatus.Listener{
@Override
public void onGpsStatusChanged(int event) {
// TODO Auto-generated method stub
switch(event){
case GpsStatus.GPS_EVENT_STARTED:Log.e("Started", "");
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:Log.e("FirstFix", "");
break;
case GpsStatus.GPS_EVENT_STOPPED:Log.e("Sopped", "");
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:GpsStatus xGpsStatus = locMgr.getGpsStatus(null) ;
Iterable<GpsSatellite> iSatellites = xGpsStatus.getSatellites() ;
Iterator<GpsSatellite> it = iSatellites.iterator() ;
while ( it.hasNext() )
{
GpsSatellite oSat = (GpsSatellite) it.next() ;
if(oSat.usedInFix()){
Log.e("A fost folosit ", "int fix!");
}
if(oSat.toString()!=null){

Log.e("Test", "SNR:"+oSat.getSnr()+"; Azimuth:"+oSat.getAzimuth()+"; Elevation:"+oSat.getElevation()+" "+oSat.toString()+"; PRN:"+oSat.getPrn());
}
}
break ;


}
}
}

public class MyLocationListener implements LocationListener{

@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub

if(location!=null){
lat = location.getLatitude();
lon = location.getLongitude();
Toast.makeText(getApplicationContext(), ""+lat+"\n"+lon, Toast.LENGTH_LONG).show();
}
}

@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub

}}

最佳答案

卫星并没有你可以随便取的名字。你能得到的最好的是 PRN,你的代码已经显示你得到了。

编辑阅读更多之后,我发现有些人试图映射 PRN 号码,尽管有时这是不正确的。尝试 http://www.losangeles.af.mil/shared/media/document/AFD-070530-036.pdf

关于android - 我可以在 android 中获取卫星名称吗?它在他们的 SNR、PNR、仰角、方位角中显示了我,但我不知道它显示给我的数据是否正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7636950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com