protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_out_request);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
startLocationService();
findViewById(R.id.checkBox1).setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
printChecked(v);
finish();
}
});
findViewById(R.id.checkBox2).setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
printChecked(v);
finish();
}
});
}
private void startLocationService() {
LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
GPSListener gpsListener = new GPSListener();
long minTime = 10000;
float minDistance = 0;
manager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
minTime,
minDistance,
gpsListener);
manager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
minTime,
minDistance,
gpsListener);
Toast.makeText(getApplicationContext(), "현재위치찾는중", Toast.LENGTH_SHORT).show();
}
public void printChecked(View v){
CheckBox ch1=(CheckBox)findViewById(R.id.checkBox1);
CheckBox ch2=(CheckBox)findViewById(R.id.checkBox2);
String resultText="";
if(ch1.isChecked()){
resultText += ch1.getText().toString();
}
if(ch2.isChecked()){
if(!"".equals(resultText))
resultText += ",";
resultText += ch2.getText().toString();
}
TextView tv =(TextView)findViewById(R.id.textView2);
tv.setText(resultText);
}
private class GPSListener implements LocationListener {
public void onLocationChanged(Location location) {
Double latitude = location.getLatitude();
Double longitude = location.getLongitude();
String msg = "Latitude : "+ latitude + "\nLongitude:"+ longitude;
Log.i("GPSLocationService", msg);
showCurrentLocation1(latitude, longitude);
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
private void showCurrentLocation1(Double latitude, Double longitude) {
LatLng curPoint = new LatLng(latitude, longitude);
map.animateCamera(CameraUpdateFactory.newLatLngZoom(curPoint, 15));
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
실행시 체크박스를 선택하면 어플이 삭제됩니다ㅜㅜ무슨문제이죠?