0
어떻게 내 위치 좌표를 안드로이드에 firebase로 보낼 수 있습니까? firebase를 사용하는 채팅 응용 프로그램을 볼 수는 있지만 실제 좌표를 보낼 수있는 내 Gps 코드를 넣는 방법을 모르겠습니다. 메시지를 모든firebase로 위치를 보낼 채팅 응용 프로그램
어떻게 내 위치 좌표를 안드로이드에 firebase로 보낼 수 있습니까? firebase를 사용하는 채팅 응용 프로그램을 볼 수는 있지만 실제 좌표를 보낼 수있는 내 Gps 코드를 넣는 방법을 모르겠습니다. 메시지를 모든firebase로 위치를 보낼 채팅 응용 프로그램
먼저이 같은 당신을 찾아야한다 모델 클래스를 만들 필요가 같은 시간 :이처럼 Activity
에 변수를 만들 필요가보다
public class MapModel {
private String latitude;
private String longitude;
public MapModel() {}
public MapModel(String latitude, String longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
public void setLatitude(String latitude) {this.latitude = latitude;}
public String getLatitude() {return latitude;}
public void setLongitude(String longitude) {this.longitude = longitude;}
public String getLongitude() {return longitude;}
}
:
private static final int PLACE_PICKER_REQUEST = 123;
은
onActivityResult
무시
그것은 다음과 같아야합니다
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST){
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
if (place != null){
LatLng latLng = place.getLatLng();
MapModel mapModel = new MapModel(latLng.latitude + "", latLng.longitude + "");
databaseReference.push().setValue(mapModel);
}
}
}
}
이 위치를 보내려면 다음과 같은 방법을 만들 :
private void locationPlacesIntent(){
try {
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
그것이 도움이되기를 바랍니다.
위치를 보내 주셨습니까? –