Search code examples
androidgoogle-mapsgeolocationgps

Calling an Object inside uriparse while opening google map using a button


Here am using a button to show a gps from one loaction to another... I am having a problem {Uri.parse("http://maps.google.com/maps?saddr=10.0515097,76.4888416&daddr="+obj.latitude,+obj.longitude));}

while using this... I am using a web service so latitude and longitude is saved as objects... I got the gps location without a coma in google map between +obj.latitude+obj.longitude{Uri.parse("http://maps.google.com/maps?saddr=10.0515097,76.4888416&daddr="+obj.latitude+obj.longitude));}

What should I do to add the comma in between them to track it

Button btn_driver = (Button) v.findViewById(R.id.btn_drivermap);
btn_driver.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        Log.d("SECOND", "doInBackground()");
        HttpEntity resEntity;


            DefaultHttpClient client = new DefaultHttpClient();
            HttpPost post = new HttpPost(Utils.WebserviceUrl + "get_drivers.php?");

            MultipartEntity reqEntity = new MultipartEntity();

            try {
                reqEntity.addPart("user_id", new StringBody(Utils.user_id));
            } catch (UnsupportedEncodingException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            try {
                reqEntity.addPart("latitude", new StringBody(String.valueOf(Utils.geo_latitude)));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                reqEntity.addPart("longitude", new StringBody(String.valueOf(Utils.geo_longitude)));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
                    Uri.parse("http://maps.google.com/maps?saddr=10.0515097,76.4888416&daddr="+obj.latitude,+obj.longitude));
                startActivity(intent);

    }});

Solution

  • Just added a plus(+) to it

    Uri.parse("http://maps.google.com/maps?saddr=10.0515097,76.4888416&daddr="+obj.latitude+","+obj.longitude));