请帮我检查这段代码,在 AsyncTask 线程的 Void doInBackground(Void... voids) 中具有正确 API_KEY 和 API_SECRET 的 amadeus api 使我的应用程序崩溃。我已经尝试了一段时间,任何建议的解决方案都将不胜感激。
@Override 受保护的 Void doInBackground(Void... voids) {
Amadeus amadeus = Amadeus.builder("API_KEY","API_SECRET").build();
try{
FlightDestination[] destination1 = amadeus.shopping.flightDestinations.get(Params.with("origin", "MAD"));
if (destination1[0].getResponse().getStatusCode() == 200) {
id = destination1[0].getType();
name = destination1[0].getOrigin();
email = destination1[0].getDestination();
date1 = destination1[0].getDepartureDate();
date2 = destination1[0].getReturnDate();
FlightDestination.Price total= destination1[0].getPrice();
double x = total.getTotal();
}
else { id = "Error";}
}catch (ClientException e)
{
//id=e.getMessage();
}catch (NetworkException e)
{
id = e.getMessage();
}catch (NotFoundException e)
{
id = e.getMessage();
}catch (ServerException e)
{
id = e.getMessage();
}catch (ParserException e)
{
id = e.getMessage();
}catch (ResponseException e)
{
id = e.getMessage();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Intent data = new Intent(SportsTickets.this, Displayinfo.class);
data.putExtra("type",id);
data.putExtra("origin",name);
data.putExtra("To",email);
data.putExtra("departureDate", address);
data.putExtra("total",gender);
startActivity(data);
pDialog.dismiss();
}