private void listPlaces() { placesList.clear(); placesListAdapter.notifyDataSetChanged(); final String url = getURL(locationLat, locationLng); searchTask = getSearchTask(url); showProgress(true); try { PlacesResponse placesResponse = searchTask.execute(null, null).get(); int pageCount = 0; while (pageCount++ < 10 && placesResponse != null && placesResponse.next_page_token != null) { Toast.makeText(getBaseContext(), "Retrieving page" + pageCount, Toast.LENGTH_SHORT).show(); searchTask = getSearchTask(getURL(placesResponse.next_page_token)); placesResponse = searchTask.execute(null, null).get(); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } showProgress(false); }