首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否显示NMEA语句?

是否显示NMEA语句?
EN

Stack Overflow用户
提问于 2011-01-13 14:54:43
回答 6查看 12.8K关注 0票数 2

任何人帮助显示像$GPRMC这样的NMEA句子.....我使用了下面的代码:

代码语言:javascript
复制
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中添加权限的任何帮助

代码语言:javascript
复制
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
EN

回答 6

Stack Overflow用户

发布于 2013-08-03 14:20:18

将您的提供程序更改为GPS_PROVIDER。

您可以通过Gps提供商获得nmea语句。

更改此行

代码语言:javascript
复制
     **lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000,10,this);**

代码语言:javascript
复制
     **lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000,10,this);**

现在签入onNmeaReceived()方法。

票数 5
EN

Stack Overflow用户

发布于 2013-07-03 14:22:16

只需添加一个NmeaListener

代码语言:javascript
复制
  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);





}
票数 4
EN

Stack Overflow用户

发布于 2011-08-05 19:05:56

我有三星Galaxy Spica,是的,它不能工作。然而,我已经安装了‘超级全球定位系统记录器’(link)和NMEA数据被正确读取。也许这个工具的作者使用了不同的解决方案来阅读NMEA,这意味着这是可能的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4677548

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档