• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Getting REQUEST_DENIED on using Google Direction API

manvinder

Newbie
Hi all,

In my project I have to get directions between 2 given places. For this i am using Directions API of google but every time I am getting REQUEST_DENIED in response. Here is the code segment I am using for the parsing to get the waypoints..

[HIGH]StringBuilder url = new StringBuilder("http://maps.googleapis.com/maps/api/directions/xml?");
StringBuilder urlParams = new StringBuilder();

urlParams.append("origin=" + params[0]);
urlParams.append("&destination=" + params[1]);
urlParams.append("&sensor=" + params[2]);

try {
Log.d(AppData.TAG , "Creating SAX Parser.");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();

routeParser = new RouteParser();

xr.setContentHandler(routeParser);
xr.parse(new InputSource((new URL(url.toString() + URLEncoder.encode(urlParams.toString(), "UTF-8"))).openStream()));
routeInformation = routeParser.getRSSPostData();

Log.d(AppData.TAG , "Direction Response Status: " + routeInformation.getStatus());
}
catch(SAXException ex) {
Log.e(AppData.TAG , ex.getMessage());
}
catch(ParserConfigurationException ex) {
Log.e(AppData.TAG , ex.getMessage());
}
catch(IOException ex) {
Log.e(AppData.TAG , ex.getMessage());
}
catch(Exception ex) {
Log.e(AppData.TAG , ex.getMessage());
}
[/HIGH]
 
Back
Top Bottom