只需根据UTC更改时间以检查...
但我在移动应用程序上得到了一个不完整的剪辑版本..
`String archiveQuery ="http://maps.googleapis.com/maps/api/directions/json?origin=RV%20College%20Bus%20Stop,%20Mysore%20Road,Bangalore,Karnataka&destination=Malleswaram,Bangalore,Karanataka,India&sensor=假&departure_time=1353850800&mode=transit&alternatives=true";
Log.d("%%%%%%%%%%%%%%%%%%%%",archiveQuery);
String arch=archiveQuery;
InputStream in = null;
String queryResult = "";
try {
URL url = new URL(arch);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) urlConn;
httpConn.setAllowUserInteraction(false);
httpConn.connect();
in = httpConn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(in);
ByteArrayBuffer baf = new ByteArrayBuffer(5000000);
int read = 0;
int bufSize = 5000000;
byte[] buffer = new byte[bufSize];
while(true){
read = bis.read(buffer);
if(read==-1){
break;
}
baf.append(buffer, 0, read);
}
queryResult = new String(baf.toByteArray());
} catch (MalformedURLException e) {
e.toString();
} catch (IOException e) {
e.toString();
}
尝试 {
JSONObject jObject;
Log.d("%%%%%%%%%%%%%%%%%%%%",queryResult);
Toast.makeText(getApplicationContext(), "FFFFFFFFFFFFF", Toast.LENGTH_LONG).show();
jObject = new JSONObject(queryResult);
JSONArray routes = jObject.getJSONArray("routes");
String statu = jObject.getString("status").toString();
if(statu.equals("OK")){
int num=routes.length();
for(int i=0;i<num;i++)
{
JSONArray legs=routes.getJSONObject(i).getJSONArray("legs");
JSONArray steps=legs.getJSONObject(0).getJSONArray("steps");
int l=steps.length();
for(int j=0;j<l;j++)
if(steps.getJSONObject(j).getString("travel_mode").toString()!="WALKING")
{
JSONObject trans=steps.getJSONObject(j).getJSONObject("transit_details");
JSONObject line=trans.getJSONObject("line");
Log.d("@@@@@@@@@@@@@@@@\n\n\n\n\n\n\n\n\n\n",line.getString("short_name").toString());
Toast.makeText(getApplicationContext(), line.getString("short_name").toString(), Toast.LENGTH_LONG).show();
}
}}
else
{
Toast.makeText(getBaseContext(), "Suggestion not available! Please search" +
"another placeor search in maps", Toast.LENGTH_SHORT).show();}
}
catch (JSONException e) {e.toString();}
` this is code i am using