Ich habe viel bei der Beseitigung der Fehler versucht, aber nicht in der Lage einen Fehler zu entfernen, die Adresse nicht kompatiblen Typinkompatiblen Typ Adresse in android
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));
}
}
bitte helfen, wie im Dialogfeld Fehler ist zeigt . Dialogfeld zeigt gefunden android.location.address erfordert Liste importieren com.google.android.gms.identity.intents.Address
In importieren com.google.android.gms.identity.intents.Address existiert, aber es erstellt inkompatiblen Fehler noch als ich die Adressliste Anweisung verwenden –
Ja, ich glaube nicht, dass Sie diesen Import wollen. Geocoder gibt android.location.Address zurück, das Sie entweder importieren oder explizit deklarieren müssen. – Ben
yeah Ich habe Geocoder noch Import ist nicht in Adressliste Anweisung passiert können Sie eine Alternative zu diesem geben, wenn ja bitte zeigen –