0

我在获取位置时遇到了这个错误。我在应用程序启动时通过模拟器控制手动发送坐标但仍然出现此错误我的代码是

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


//for getting location
        lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        ll = new MyLocationListener(etTextOut);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0 , 0, ll);
}

我的位置类是

public class MyLocationListener implements LocationListener {

EditText etTextOut;

public MyLocationListener(EditText etTextOut) {
    // TODO Auto-generated constructor stub
    this.etTextOut = etTextOut;
}

//public TextView tv;
@Override
public void onLocationChanged(Location loc) {
    // TODO Auto-generated method stub

    loc.getLongitude();
            loc.getLatitude();

    String msg = "Latitude:" + loc.getLatitude() + "\nLongitude:" + loc.getLongitude();

     etTextOut.setText(msg);



}

我想在主类的edittext中设置我的坐标并通过套接字将其发送到PC

4

0 回答 0