使用OSMdroid mapview使地图和微调器处于活动状态会导致logcat中出现多个“活动已暂停”和“活动已恢复”

问题描述

我正在制作一个Activity,该Activity在屏幕顶部包含一个小微调框,其余的填充有地图。微调器包含一些包含在地图中的标记,因此,当您选择微调器中的一个标记(它们是不同的办公室)时,地图将以该标记为中心并打开其infoWindow。

一切正常,我可以创建地图并将其移动到想要的位置,填充微调框,每当我选择一个地图时,它就可以按照我想要的去做。我的问题是,由于某种原因,该活动不会停止暂停和继续。这是我的logcat的样子:

2020-11-07 19:08:54.290 25037-25165/com.example.adictic V/FA: Activity paused,time: 328516383
2020-11-07 19:08:54.376 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328516495
2020-11-07 19:08:54.407 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 12
2020-11-07 19:08:54.409 25037-25165/com.example.adictic V/FA: Activity paused,time: 328516507
2020-11-07 19:08:54.508 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328516627
2020-11-07 19:08:54.543 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 12
2020-11-07 19:08:54.554 25037-25165/com.example.adictic V/FA: Activity paused,time: 328516639
2020-11-07 19:08:54.642 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328516761
2020-11-07 19:08:54.672 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 20
2020-11-07 19:08:54.673 25037-25165/com.example.adictic V/FA: Activity paused,time: 328516781
2020-11-07 19:08:54.769 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328516888
2020-11-07 19:08:54.797 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 23
2020-11-07 19:08:54.802 25037-25165/com.example.adictic V/FA: Activity paused,time: 328516911
2020-11-07 19:08:54.898 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517017
2020-11-07 19:08:54.936 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 20
2020-11-07 19:08:54.941 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517037
2020-11-07 19:08:55.038 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517158
2020-11-07 19:08:55.083 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 28
2020-11-07 19:08:55.089 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517187
2020-11-07 19:08:55.174 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517292
2020-11-07 19:08:55.208 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 30
2020-11-07 19:08:55.216 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517322
2020-11-07 19:08:55.298 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517417
2020-11-07 19:08:55.335 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 33
2020-11-07 19:08:55.342 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517450
2020-11-07 19:08:55.460 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517579
2020-11-07 19:08:55.493 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 26
2020-11-07 19:08:55.501 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517605
2020-11-07 19:08:55.659 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517778
2020-11-07 19:08:55.708 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 16
2020-11-07 19:08:55.711 25037-25165/com.example.adictic V/FA: Activity paused,time: 328517794
2020-11-07 19:08:55.844 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328517963
2020-11-07 19:08:55.890 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 37
2020-11-07 19:08:55.894 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518000
2020-11-07 19:08:56.066 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518185
2020-11-07 19:08:56.102 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 18
2020-11-07 19:08:56.121 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518203
2020-11-07 19:08:56.302 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518420
2020-11-07 19:08:56.337 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 29
2020-11-07 19:08:56.340 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518450
2020-11-07 19:08:56.467 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518586
2020-11-07 19:08:56.503 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 26
2020-11-07 19:08:56.511 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518612
2020-11-07 19:08:56.582 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518700
2020-11-07 19:08:56.615 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 20
2020-11-07 19:08:56.624 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518721
2020-11-07 19:08:56.715 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518834
2020-11-07 19:08:56.749 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 24
2020-11-07 19:08:56.751 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518859
2020-11-07 19:08:56.841 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328518961
2020-11-07 19:08:56.879 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 27
2020-11-07 19:08:56.882 25037-25165/com.example.adictic V/FA: Activity paused,time: 328518988
2020-11-07 19:08:56.979 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328519099
2020-11-07 19:08:57.007 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 12
2020-11-07 19:08:57.008 25037-25165/com.example.adictic V/FA: Activity paused,time: 328519111
2020-11-07 19:08:57.107 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328519226
2020-11-07 19:08:57.172 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 25
2020-11-07 19:08:57.174 25037-25165/com.example.adictic V/FA: Activity paused,time: 328519252
2020-11-07 19:08:57.250 25037-25165/com.example.adictic V/FA: Activity resumed,time: 328519369
2020-11-07 19:08:57.272 25037-25165/com.example.adictic V/FA: Screen exposed for less than 1000 ms. 

无休止的循环。

“我的布局”非常简单,您可以在这里看到它只有地图视图和微调器。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Spinner
        android:id="@+id/SP_listoficines"
        android:layout_width="253dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <org.osmdroid.views.MapView
        android:id="@+id/MV_map"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/SP_listoficines" />
</androidx.constraintlayout.widget.ConstraintLayout>
package com.example.adictic.activity;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.text.LineBreaker;
import android.icu.text.IDNA;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.example.adictic.R;
import com.example.adictic.TodoApp;
import com.example.adictic.entity.Oficina;
import com.example.adictic.rest.TodoApi;

import org.mapsforge.map.android.layers.MyLocationOverlay;
import org.osmdroid.api.IMapController;
import org.osmdroid.api.IMapView;
import org.osmdroid.config.Configuration;
import org.osmdroid.events.MapEventsReceiver;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Marker;
import org.osmdroid.views.overlay.infowindow.BasicInfoWindow;
import org.osmdroid.views.overlay.infowindow.InfoWindow;
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static android.content.Intent.ACTION_DIAL;

/** https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/java/org/osmdroid/StarterMapFragment.java **/

public class OficinesActivity extends AppCompatActivity {
    private final int REQUEST_PERMISSIONS_REQUEST_CODE = 1;

    private TodoApi mTodoService;

    private MapView map = null;

    private static final String TAG = OficinesActivity.class.getSimpleName();

    private Spinner SP_oficines;

    private List<Oficina> oficines = new ArrayList<>();

    private static final long MIN_disTANCE_CHANGE_FOR_UPDATES = 10; // 10 metres
    private static final long MIN_TIME_FOR_UPDATES = 1000*60; // 1 minut

    private GeoPoint currentLocation;
    MyLocationListener locationListener;
    LocationManager locationManager;

    MyLocationNewOverlay myLocationOverlay;

    ArrayList<Marker> markers = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //load/initialize the osmdroid configuration,this can be done
//        Context ctx = getApplicationContext();
//        Configuration.getInstance().load(ctx,PreferenceManager.getDefaultSharedPreferences(ctx));
        //setting this before the layout is inflated is a good idea
        //it 'should' ensure that the map has a writable location for the map cache,even without permissions
        //if no tiles are displayed,you can try overriding the cache path using Configuration.getInstance().setCachePath
        //see also StorageUtils
        //note,the load method also sets the HTTP User Agent to your application's package name,abusing osm's
        //tile servers will get you banned based on this string

        setContentView(R.layout.oficines_layout);
        SP_oficines = findViewById(R.id.SP_listoficines);

        mTodoService = ((TodoApp) getApplication()).getAPI();

        // Actualitzem la llista d'oficines
        Call<List<Oficina>> call = mTodoService.getoficines();
        call.enqueue(new Callback<List<Oficina>>() {
            @Override
            public void onResponse(Call<List<Oficina>> call,Response<List<Oficina>> response) {
                if (response.isSuccessful()) {
                    oficines = response.body();
                    TodoApp.setoficines(oficines);
                    setMap();
                } else {
                    oficines = TodoApp.getoficines();
                    setMap();
                }
            }

            @Override
            public void onFailure(Call<List<Oficina>> call,Throwable t) {
                oficines = TodoApp.getoficines();
                setMap();
            }
        });
    }

    @SuppressLint("MissingPermission")
    private void setMap() {
        map = (MapView) findViewById(R.id.MV_map);
        map.setTileSource(TileSourceFactory.MAPNIK);

        requestPermissionsIfNecessary(new String[]{
                // if you need to show the current location,uncomment the line below
                Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION,// WRITE_EXTERNAL_STORAGE is required in order to show the map
                Manifest.permission.WRITE_EXTERNAL_STORAGE
        });

        locationListener = new MyLocationListener();
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if(isNetworkEnabled){
//            locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER,null);
            locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,MIN_TIME_FOR_UPDATES,MIN_disTANCE_CHANGE_FOR_UPDATES,locationListener);

            Log.d(TAG,"Network Enabled");

            Location location = locationManager.getLastKNownLocation(LocationManager.NETWORK_PROVIDER);
            if( location != null ) {
                currentLocation = new GeoPoint(location.getLatitude(),location.getLongitude());
            }
        }
        else if(isGPSEnabled){
//            locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER,null);
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,"GPS Enabled");

            Location location = locationManager.getLastKNownLocation(LocationManager.GPS_PROVIDER);
            if( location != null ) {
                currentLocation = new GeoPoint(location.getLatitude(),location.getLongitude());
            }
        }

        myLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(getApplicationContext()),map);
        myLocationOverlay.enableMyLocation();
        map.getoverlays().add(myLocationOverlay);

        locationManager.removeUpdates(locationListener);

        map.setMultiTouchControls(true);

        IMapController mapController = map.getController();
        mapController.setZoom(17.0);

//        myLocationOverlay = new MyLocationNewOverlay(map);
//        myLocationOverlay.enableMyLocation();
//        myLocationOverlay.setDrawAccuracyEnabled(true);
//        map.getoverlays().add(myLocationOverlay);

        for(Oficina oficina : oficines){
            Marker marker = new Marker(map);
            marker.setPosition(new GeoPoint(oficina.latitude,oficina.longitude));
            marker.setTitle(oficina.name);
            OficinaInfoWindow infoWindow = new OficinaInfoWindow(R.layout.oficina_info,map,oficina);

            marker.setInfoWindow(infoWindow);

            marker.setRelatedobject(oficina);

            marker.setonMarkerClickListener(new Marker.OnMarkerClickListener() {
                @Override
                public boolean onMarkerClick(Marker marker,MapView mapView) {
                    if(marker.isInfoWindowShown()) InfoWindow.closeAllInfoWindowsOn(map);
                    else{
                        int pos = markers.indexOf(marker);
                        SP_oficines.setSelection(pos);
                        marker.showInfoWindow();
                        map.getController().setCenter(setInfoWindowOffset(marker.getPosition()));
                    }

                    return true;
                }
            });

            markers.add(marker);
            map.getoverlays().add(marker);
        }


        GeoPoint startPoint;
        if(currentLocation != null){
            markers = sortListbydistance(markers,currentLocation);
            startPoint = currentLocation;
        }
        else{
            startPoint = new GeoPoint(41.981177,2.818997); // Oficina Girona
        }

        if(!markers.isEmpty()) startPoint = markers.get(0).getPosition();

        mapController.setCenter(startPoint);
        setSpinner();
    }

    public GeoPoint setInfoWindowOffset(GeoPoint gp){
        return new GeoPoint(gp.getLatitude()+0.0025,gp.getLongitude());
    }

    @Override
    public void onResume() {
        super.onResume();

        if (map!=null) {
            map.onResume();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        //this will refresh the osmdroid configuration on resuming.
        //if you make changes to the configuration,use
        //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        //Configuration.getInstance().save(this,prefs);
        map.onPause();  //needed for compass,my location overlays,v6.0.0 and up
    }

    @Override
    public void onRequestPermissionsResult(int requestCode,String[] permissions,int[] grantResults) {
        ArrayList<String> permissionsToRequest = new ArrayList<>();
        for (int i = 0; i < grantResults.length; i++) {
            permissionsToRequest.add(permissions[i]);
        }
        if (permissionsToRequest.size() > 0) {
            ActivityCompat.requestPermissions(
                    this,permissionsToRequest.toArray(new String[0]),REQUEST_PERMISSIONS_REQUEST_CODE);
        }
    }

    private void requestPermissionsIfNecessary(String[] permissions) {
        ArrayList<String> permissionsToRequest = new ArrayList<>();
        for (String permission : permissions) {
            if (ContextCompat.checkSelfPermission(this,permission)
                    != PackageManager.PERMISSION_GRANTED) {
                // Permission is not granted
                permissionsToRequest.add(permission);
            }
        }
        if (permissionsToRequest.size() > 0) {
            ActivityCompat.requestPermissions(
                    this,REQUEST_PERMISSIONS_REQUEST_CODE);
        }
    }

    private void setSpinner(){

        MarkerAdapter adapter =
                new MarkerAdapter(getApplicationContext(),markers);

        SP_oficines.setonItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView,View view,int i,long l) {
                Marker marker = markers.get(i);
                InfoWindow.closeAllInfoWindowsOn(map);
                map.getController().setCenter(setInfoWindowOffset(marker.getPosition()));
                marker.showInfoWindow();
            }

            @Override
            public void onnothingSelected(AdapterView<?> adapterView) { }
        });

        SP_oficines.setAdapter(adapter);
        SP_oficines.setSelection(0);
    }

    private class MarkerAdapter extends BaseAdapter {
        Context context;
        LayoutInflater inflter;
        List<Marker> markers;

        public MarkerAdapter(@NonNull Context context,List<Marker> m) {
            this.context = context;
            inflter = (LayoutInflater.from(context));
            markers = m;
        }

        @Override
        public int getCount() {
            return markers.size();
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @NonNull
        @Override
        public View getView(int position,View convertView,ViewGroup parent) {
            Marker marker = markers.get(position);
            Oficina oficina = (Oficina) marker.getRelatedobject();

            View row = inflter.inflate(R.layout.oficina_spinner_item,null);
            TextView TV_nomOficina = (TextView)row.findViewById(R.id.TV_nomOficina);
            TextView TV_oficinaCiutat = (TextView)row.findViewById(R.id.TV_oficinaCiutat);

            TV_nomOficina.setText(oficina.name);
            String ciutat = "("+oficina.ciutat.toupperCase()+")";
            TV_oficinaCiutat.setText(ciutat);

            return row;
        }
    }

    public static ArrayList<Marker> sortListbydistance(ArrayList<Marker> markers,final GeoPoint location){
        Collections.sort(markers,new Comparator<Marker>() {
            @Override
            public int compare(Marker marker2,Marker marker1) {
                //
                if(getdistanceBetweenPoints(marker1.getPosition().getLatitude(),marker1.getPosition().getLongitude(),location.getLatitude(),location.getLongitude())>getdistanceBetweenPoints(marker2.getPosition().getLatitude(),marker2.getPosition().getLongitude(),location.getLongitude())){
                    return -1;
                } else {
                    return 1;
                }
            }
        });
        return markers;
    }


    public static float getdistanceBetweenPoints(double firstLatitude,double firstLongitude,double secondLatitude,double secondLongitude) {
        float[] results = new float[1];
        Location.distanceBetween(firstLatitude,firstLongitude,secondLatitude,secondLongitude,results);
        return results[0];
    }

    private class OficinaInfoWindow extends InfoWindow {

        protected Marker mMarkerRef;
        protected Oficina oficina;

        public OficinaInfoWindow(int layoutResId,MapView mapView,Oficina o) {
            super(layoutResId,mapView);
            oficina = o;
        }

        public void onopen(Object item) {
            mMarkerRef = (Marker)item;

            if (mView==null) {
                Log.w(IMapView.LOGTAG,"Error trapped,OficinaInfoWindow.open,mView is null!");
                return;
            }

            TextView TV_nomOficina = (TextView)mView.findViewById(R.id.TV_nomOficina);
            TextView TV_descOficina = (TextView)mView.findViewById(R.id.TV_descOficina);
            TextView TV_addressOficina = (TextView)mView.findViewById(R.id.TV_addressOficina);
            Button BT_telfOficina = (Button)mView.findViewById(R.id.BT_telfOficina);

            TV_nomOficina.setText(oficina.name);
            TV_descOficina.setText(oficina.description);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                TV_descOficina.setJustificationMode(LineBreaker.JUSTIFICATION_MODE_INTER_WORD);
            }

            String address = oficina.address + ". " + oficina.ciutat.toupperCase();
            TV_addressOficina.setText(address);
            BT_telfOficina.setText(oficina.telf);
            BT_telfOficina.setonClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    String telf = oficina.telf.replace("[^\\d+]","");
                    Intent intent = new Intent(ACTION_DIAL);
                    intent.setData(Uri.parse("tel:"+telf));
                    startActivity(intent);
                }
            });
        }

        @Override
        public void onClose() { }
    }


    class MyLocationListener implements LocationListener {

        public void onLocationChanged(Location location) {
            currentLocation = new GeoPoint(location);
            //displayMyCurrentLocationOverlay();
        }

        public void onProviderdisabled(String provider) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onStatusChanged(String provider,int status,Bundle extras) {
        }
    }

//    private void displayMyCurrentLocationOverlay() {
//        if( currentLocation != null) {
//            if( myLocationOverlay == null ) {
//                new Arrayitemizedoverlay
//                myLocationOverlay = new Arrayitemizedoverlay(myLocationMarker);
//                myCurrentLocationOverlayItem = new OverlayItem(currentLocation,"My Location","My Location!");
//                myLocationOverlay.addItem(myCurrentLocationOverlayItem);
//                mapView.getoverlays().add(myLocationOverlay);
//            } else {
//                myCurrentLocationOverlayItem.setPoint(currentLocation);
//                myLocationOverlay.requestRedraw();
//            }
//            map.getController().setCenter(currentLocation);
//        }
//    }
}

这是一项巨大的活动,对此我感到抱歉。

一个简单的演练:在OnCreate方法中,我从服务器获取办公室,然后转到内置所有内容setMap()

首先,它会询问是否需要授予必要的权限,然后寻找用户的当前位置。

使用for为每个办公室创建一个标记,并将其与其infoWindow放在地图上。完成后,它仅按距离(最近到最远)对标记列表进行排序,然后设置微调器。

我不知道为什么该活动不会停止暂停和继续,并且由于这样做,我不得不向垃圾邮件单击微调器以将其打开,因为如果在暂停时单击它,它将无法打开,因此一切都很顺畅。

非常感谢您!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...