任何人帮助显示像$GPRMC这样的NMEA句子.....我使用了下面的代码:
public class SampleNMEA extends Activity implements LocationListener, GpsStatus.Listener,GpsStatus.NmeaListener{
LocationManager lm;
TextView output;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
output = (TextView)findViewById(R.id.out);
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);
final Location location=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
output.append("\nBelow Data is about the your location:");
output.append("\n\n\nLatit:"+location.getLatitude());
output.append("\n\nLongitude:"+location.getLongitude());
output.append("\n\nTime: "+location.getTime());
}
public void onLocationChanged(Location location)
{
output.append("\n\n\nLatitude:"+location.getLatitude());
output.append("\n\nLongitude:"+location.getLongitude());
output.append("\n\nTime: "+location.getTime());
}
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String arg0, int arg1, Bundle arg2)
{
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);
final Location location=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
output.append("\n\n\nLatitude:"+location.getLatitude());
output.append("\n\nLongitude:"+location.getLongitude());
output.append("\n\nTime: "+location.getTime());
}
public void onGpsStatusChanged(int event)
{
}
public void onNmeaReceived(long timestamp, String nmea)
{
output.append("NMEA Sentence: "+nmea);
}
}我在manifest.xml中添加权限的任何帮助
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>发布于 2013-08-03 14:20:18
将您的提供程序更改为GPS_PROVIDER。
您可以通过Gps提供商获得nmea语句。
更改此行
**lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);**至
**lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000,10,this);**现在签入onNmeaReceived()方法。
发布于 2013-07-03 14:22:16
只需添加一个NmeaListener
public class SampleNMEA extends Activity implements LocationListener, GpsStatus.Listener,GpsStatus.NmeaListener{
LocationManager lm;
TextView output;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
output = (TextView)findViewById(R.id.out);
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);
final Location location=lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
output.append("\nBelow Data is about the your location:");
output.append("\n\n\nLatit:"+location.getLatitude());
output.append("\n\nLongitude:"+location.getLongitude());
output.append("\n\nTime: "+location.getTime());
//add listener here
lm.AddNmeaListener(this);
}发布于 2011-08-05 19:05:56
我有三星Galaxy Spica,是的,它不能工作。然而,我已经安装了‘超级全球定位系统记录器’(link)和NMEA数据被正确读取。也许这个工具的作者使用了不同的解决方案来阅读NMEA,这意味着这是可能的。
https://stackoverflow.com/questions/4677548
复制相似问题