org.client.andorid.MyLocationListener.onLocationChanged(MyLocationListener.java:29)中的java.lang.NullPointerException错误

时间:2012-09-22 20:50:00

标签: eclipse android-emulator location

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

    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中设置我的coordiantes并通过套接字将其发送到PC

0 个答案:

没有答案