android - AsyncTask not getting executed more than one
问题描述
i am initiating direction api to draw polyline,calling asyncTask in oncreate, but its not getting called second time onwords even opening activity again and again. after removing app from recent apps and opening it again works for a single time.here is my code.
private void moveCamera(LatLng originLatLng, LatLng endLatLng) {
mMap.addMarker(new MarkerOptions().position(currentLatLng).title("Starting Location").icon(BitmapDescriptorFactory.fromResource(R.mipmap.pickup_location)));
HelperFunctions.addOverlay(currentLatLng, mMap, SpeedMediatorActivity.this);
if (endLatLng != null) {
mMap.addMarker(new MarkerOptions().position(destLatlng).title("Destination Location").icon(BitmapDescriptorFactory.fromResource(R.mipmap.pickup_location)));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(originLatLng);
builder.include(endLatLng);
LatLngBounds bounds = builder.build();
int padding = 50; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
String url = getDirectionsUrl(currentLatLng, destLatlng);
// Start downloading json data from Google Directions API
new DownloadTask().execute(url);
} else {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(originLatLng, 16));
}
// new FetchURL(SpeedMediatorActivity.this).execute(getUrl(originLatLng, endLatLng, "driving"), "driving");
}
Can someone help me please.
解决方案
推荐阅读
- selenium-webdriver - 如何使用键和弦功能自动化 Ctrl+n
- jupyter-notebook - 如何为 jupyter notebook 设置 PYTHONHASHSEED?
- mysql - 用于计算多对多数据的高性能查询
- c# - 使用使用服务引用的 DLL 文件
- protractor - 量角器 - 将值从一个描述 /IT 块传递到另一个
- postgresql - Spring Boot 1.5.3 创建比 application.properties 中指定更多的连接
- oracle - TKPROF 输出中的 Starts 数据是什么?
- r - 遇到 R 闪亮错误:非数字矩阵范围
- qt - 滚动时如何管理ListView中item的位置
- java - Hazelcast spring 模式配置错误