/ / GPS Vyhľadávanie v aplikácii pre Android [duplikát] - android, gps

Vyhľadávanie GPS v aplikácii Android [duplicitné] - android, gps

Musím sa navigovať cez andress, alebo premeniť svoju adresu na lat & long na použitie v uri ...

Každý, kto vie, ako to mám urobiť?

        @Override
public void onClick(View v) {
String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", 231, 321, "Where the party is at");
Intent MapsIntent= new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(uri));
MapsIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
try
{
startActivity(MapsIntent);
}
catch(ActivityNotFoundException ex)
{
try
{
Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(unrestrictedIntent);
}
catch(ActivityNotFoundException innerEx)
{
Toast.makeText(getApplicationContext(),
"Nenhum aplicativo de navegação instalado!", Toast.LENGTH_LONG).show();
}
}

}
});

odpovede:

0 pre odpoveď č. 1

na prevod adresy na lat a lng používam toto:

              String addressStr = "your address";
double latitude,longtitude;
Geocoder geoCoder = new Geocoder(context);

try {
List<Address> addresses = geoCoder.getFromLocationName(addressStr, 1);
if (addresses.size() >  0) {
latitude = addresses.get(0).getLatitude();
longtitude = addresses.get(0).getLongitude();
}

} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace(); }