Code example for Address

Methods: getLatitude, getLongitude, hasLatitude, hasLongitude

0
            else 
            { 
            Address source_address = source_addressList.get(0);
            Address destination_address = destination_addressList.get(0);
             
            if(source_address.hasLatitude() && source_address.hasLongitude() && destination_address.hasLatitude() && destination_address.hasLongitude()){
            	String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+source_address.getLatitude()+","+source_address.getLongitude()+"&daddr="+destination_address.getLatitude()+","+destination_address.getLongitude();
                Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
                 
                // Below line will open the app in google maps by default. If you don't use the following line of code, then a dialog box will appear from which user can choose which option to select. 
                intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                startActivity(intent);
                //Toast.makeText(GeocoderActivity.this,"Address : "+address.getAddressLine(0)+"\nCountry : "+address.getCountryName()+"\nLatitute : "+address.getLatitude()+"\nLongitute : "+address.getLongitude(),Toast.LENGTH_LONG).show(); 
            } 
            } 
        } 
}