AsyncTask不会执行超过一个

时间:2019-03-25 13:48:03

标签: android polyline direction google-maps-direction-api

我正在启动api绘制折线,在oncreate中调用asyncTask,但是第二次onwords甚至一次又一次地打开活动都没有被调用。从最近的应用程序中删除应用程序并再次将其打开后,可以运行一次。这是我的代码。

    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");
    }

有人可以帮我吗?

0 个答案:

没有答案