javascript – Directions API on Android Key_API-ThrowExceptions

Exception or error:

I have an Android application and I have linked it with the hosting server and things are good, but for Google Map I have a problem because I want to use the direction between two points in the map I have created a API_Key but I do not know the steps that must be followed

private void getDirectionsUrl(LatLng picklatlng,LatLng droplatlng){
        if(picklatlng!=null && droplatlng!=null) {
            String str_origin = "origin=" + picklatlng.latitude + "," + picklatlng.longitude;
            String str_dest = "destination=" + droplatlng.latitude + "," + droplatlng.longitude;
            String sensor = "sensor=false";
            String parameters = str_origin + "&" + str_dest + "&" + sensor;
            String output = "json";
            String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;
            DownloadTask downloadTask = new DownloadTask();
            downloadTask.execute(url);
        }
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *