@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
updateBtn = (Button) this.findViewById(R.id.update);
sendBtn = (Button) this.findViewById(R.id.send);
utc = (TextView) this.findViewById(R.id.val_UTC);
dataStatus = (TextView) this.findViewById(R.id.val_data_status);
currentLatitude = (TextView) this
.findViewById(R.id.val_current_latitude);
currentLontitude = (TextView) this
.findViewById(R.id.val_current_longitude);
direction = (TextView) this.findViewById(R.id.val_direction);
speed = (TextView) this.findViewById(R.id.val_speed);
locationlisterner = new TraceMeLocationListener(this);
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
0, locationlisterner);
updateBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Location location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateLocationInfo(location);
}
});
sendBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Location location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateLocationInfo(location);
try {
sendMyLocation(location);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
asasassa
最新推荐文章于 2021-03-27 09:04:19 发布
