gpt4 book ai didi

javascript - 从经纬度数据包转移到 NMEA 数据包

转载 作者:行者123 更新时间:2023-11-30 06:38:50 27 4
gpt4 key购买 nike

我正在从 lat long 项目中添加简单的 NMEA,Lat long 工作得很好,但是当转移到 nmea 时它给我错误。

如果有人能帮助我,我将不胜感激。

protected LocationManager locationManager;
protected Button retrieveLocationButton;

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

retrieveLocationButton = (Button) findViewById(R.id.retrieve_location_button);

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000,0,this);
locationManager.addNmeaListener(this);

retrieveLocationButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showCurrentLocation();
}
});
}



protected void showCurrentLocation() {
// TODO Auto-generated method stub

}

@SuppressWarnings("unused")
private class MyLocationListener implements NmeaListener {

public void onLocationChanged(Location location) {
String message = String.copyValueOf(null);

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);

boolean isGood = locationManager.addNmeaListener((NmeaListener) this);

Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
}

public void onStatusChanged(String s, int i, Bundle b) {
Toast.makeText(MainActivity.this, "Provider status changed",
Toast.LENGTH_LONG).show();
}

public void onProviderDisabled(String s) {
Toast.makeText(MainActivity.this,
"Provider disabled by the user. GPS turned off",
Toast.LENGTH_LONG).show();
}

public void onProviderEnabled(String s) {
Toast.makeText(MainActivity.this,
"Provider enabled by the user. GPS turned on",
Toast.LENGTH_LONG).show();
}

}

}

最佳答案

您并没有真正提供有关“错误”的足够信息,但在我看来,以下行会导致编译时错误...

locationManager.addNmeaListener(this);

尝试将其更改为...

locationManager.addNmeaListener(new MyLocationListener());

关于javascript - 从经纬度数据包转移到 NMEA 数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12915358/

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