0
안드로이드
에서 나는 오류를 제거하는 많은 시도했지만 수없는 호환되지 않는 유형의 주소호환되지 않는 유형의 주소는
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
EditText ed;
Button btn;
private GoogleMap mMap;
List<Address> addressList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
ed=(EditText)findViewById(R.id.ed);
btn=(Button)findViewById(R.id.btn);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
public void onsearch()
{
String location=ed.getText().toString();
if(location!=null|| !location.equals("")){
Geocoder geocoder=new Geocoder(this);
try {
addressList=geocoder.getFromLocationName(location,1);
} catch (IOException e) {
e.printStackTrace();
}
Address address=addressList.get(0);
LatLng latLng=new LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("marker"));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
오류 대화 상자로 도와주세요 을 보여줍니다에게 하나 오류를 제거 할 수 있습니다. 대화 상자에 발견 된 android.location.address가 필요합니다. 목록 가져 오기 com.google.android.gms.identity.intents.Address
가져 오기 com.google.android.gms.identity.intents.Address가 있지만 주소 목록 문을 사용하는 경우에도 여전히 호환되지 않는 오류가 발생합니다 –
그렇습니다. 가져 오기를 원하지 않습니다. Geocoder는 android.location.Address를 반환합니다. 주소를 가져 오거나 명시 적으로 주소 변수를 선언해야합니다. – Ben
예 지오 코더를 사용했습니다. 여전히 가져 오기가 주소 목록 문에서 일어나지 않습니다.이 경우에 대한 대안을 제공 할 수 있습니까? –