未检索纬度和经度

Latitude and longitude not retrieved

当 gps 被禁用时,您可以使用 Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 启用它,但是当我返回 activity 时,我没有得到任何结果。我必须重新启动 activity,换句话说,我必须回到之前的 activity,然后重新打开它。请你帮助我好吗?

这是我的doInBackground方法:

@Override
protected String doInBackground(String... uri){

    final GPSTracker gpsTracker = new GPSTracker(myactivity);
    final String[] latitudine = {null};
    final String[] longitudine = {null};

    if(gpsTracker.canGetLocation())
    {
        latitudine[0] = String.valueOf(gpsTracker.latitude);
        longitudine[0] = String.valueOf(gpsTracker.longitude);
    }
    else
    {
        myactivity.runOnUiThread(new Runnable() {
            public void run() {

                final Dialog dialog = new Dialog(myactivity);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.position_alert_dialog);

                Button dialogButton_deny = (Button) dialog.findViewById(R.id.deny);
                Button dialogButton_allow = (Button) dialog.findViewById(R.id.allow);

                dialogButton_allow.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        myactivity.startActivity(intent);
                        dialog.dismiss();

                        if(gpsTracker.canGetLocation())
                        {
                            latitudine[0] = String.valueOf(gpsTracker.latitude);
                            longitudine[0] = String.valueOf(gpsTracker.longitude);

                        }else{

                            latitudine[0] = "34.0522300";
                            longitudine[0] = "-118.2436800";

                        }

                    }
                });

                dialogButton_deny.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });

                dialog.show();

            }
        });
    }

GPSTracker:

public class GPSTracker extends Service implements LocationListener {
    private final Context mContext;

    boolean isGPSEnabled = false;

    boolean isNetworkEnabled = false;

    boolean canGetLocation = false;

    Location location;
    double latitude;
    double longitude;

    private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; //10 meters

    private static final long MIN_TIME_BW_UPDATES = 1000 * 60; // 1 minute

    protected LocationManager locationManager;

    public GPSTracker(Context context) {
        this.mContext = context;
        getLocation();
    }

    public Location getLocation() {
        try {
            locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

            isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

            isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

            if (!isGPSEnabled && !isNetworkEnabled) {
            } else {
                this.canGetLocation = true;
                if (isNetworkEnabled) {
                    locationManager.requestLocationUpdates(
                            LocationManager.NETWORK_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this, Looper.getMainLooper());

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

                    if (locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                        updateGPSCoordinates();
                    }
                }
                if (isGPSEnabled) {
                    if (location == null) {
                        locationManager.requestLocationUpdates(
                                LocationManager.GPS_PROVIDER,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                        Log.d("GPS Enabled", "GPS Enabled");

                        if (locationManager != null) {
                            location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                            updateGPSCoordinates();
                        }
                    }
                }
            }
        } catch (Exception e) {
            //e.printStackTrace();
            Log.e("Error : Location", "Impossible to connect to LocationManager", e);
        }

        return location;
    }

    public void updateGPSCoordinates() {
        if (location != null) {
            latitude = location.getLatitude();
            longitude = location.getLongitude();
        }
    }

    public void stopUsingGPS() {
        if (locationManager != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    // TODO: Consider calling
                    //    public void requestPermissions(@NonNull String[] permissions, int requestCode)
                    // here to request the missing permissions, and then overriding
                    //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                    //                                          int[] grantResults)
                    // to handle the case where the user grants the permission. See the documentation
                    // for Activity#requestPermissions for more details.
                    return;
                }
            }
            locationManager.removeUpdates(GPSTracker.this);
        }
    }

    public double getLatitude()
    {
        if (location != null)
        {
            latitude = location.getLatitude();
        }

        return latitude;
    }

    public double getLongitude()
    {
        if (location != null)
        {
            longitude = location.getLongitude();
        }

        return longitude;
    }

    public boolean canGetLocation()
    {
        return this.canGetLocation;
    }

    public List<Address> getGeocoderAddress(Context context)
    {
        if (location != null)
        {
            Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);
            try
            {
                return geocoder.getFromLocation(latitude, longitude, 1);
            }
            catch (IOException e)
            {
                //e.printStackTrace();
                Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e);
            }
        }

        return null;
    }

    public String getAddressLine(Context context)
    {
        List<Address> addresses = getGeocoderAddress(context);
        if (addresses != null && addresses.size() > 0)
        {
            Address address = addresses.get(0);

            return address.getAddressLine(0);
        }
        else
        {
            return null;
        }
    }

    public String getLocality(Context context)
    {
        List<Address> addresses = getGeocoderAddress(context);
        if (addresses != null && addresses.size() > 0)
        {
            Address address = addresses.get(0);

            return address.getLocality();
        }
        else
        {
            return null;
        }
    }

    public String getSubLocality(Context context)
    {
        List<Address> addresses = getGeocoderAddress(context);
        if (addresses != null && addresses.size() > 0)
        {
            Address address = addresses.get(0);

            return address.getSubLocality();
        }
        else
        {
            return null;
        }
    }

    public String getPostalCode(Context context)
    {
        List<Address> addresses = getGeocoderAddress(context);
        if (addresses != null && addresses.size() > 0)
        {
            Address address = addresses.get(0);

            return address.getPostalCode();
        }
        else
        {
            return null;
        }
    }

    public String getCountryName(Context context)
    {
        List<Address> addresses = getGeocoderAddress(context);
        if (addresses != null && addresses.size() > 0)
        {
            Address address = addresses.get(0);

            return address.getCountryName();
        }
        else
        {
            return null;
        }
    }

    @Override
    public void onLocationChanged(Location location)
    {
    }

    @Override
    public void onProviderDisabled(String provider)
    {
    }

    @Override
    public void onProviderEnabled(String provider)
    {
    }    

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

    @Override
    public IBinder onBind(Intent intent)
    {
        return null;
    }
}

编辑

public class GPSTracker extends Service implements LocationListener, GoogleApiClient.ConnectionCallbacks {
private final Context mContext;

boolean isPlayServicesEnabled = false;

boolean isGPSEnabled = false;

boolean isNetworkEnabled = false;

boolean canGetLocation = false;

Location location;
double latitude;
double longitude;

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; //10 meters

private static final long MIN_TIME_BW_UPDATES = 1000 * 60; // 1 minute

protected LocationManager locationManager;

public GPSTracker(Context context) {
    this.mContext = context;
}

public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this, Looper.getMainLooper());

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

                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    updateGPSCoordinates();
                }
            }
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                    Log.d("GPS Enabled", "GPS Enabled");

                    if (locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        updateGPSCoordinates();
                    }
                }
            }
        }
    } catch (Exception e) {
        //e.printStackTrace();
        Log.e("Error : Location", "Impossible to connect to LocationManager", e);
    }

    return location;
}

public void updateGPSCoordinates() {
    if (location != null) {
        latitude = location.getLatitude();
        longitude = location.getLongitude();
    }
}

public void stopUsingGPS() {
    if (locationManager != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    public void requestPermissions(@NonNull String[] permissions, int requestCode)
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for Activity#requestPermissions for more details.
                return;
            }
        }
        locationManager.removeUpdates(GPSTracker.this);
    }
}

public double getLatitude() {
    if (location != null) {
        latitude = location.getLatitude();
    }

    return latitude;
}

public double getLongitude() {
    if (location != null) {
        longitude = location.getLongitude();
    }

    return longitude;
}

public boolean canGetLocation() {
    return this.canGetLocation;
}

public List<Address> getGeocoderAddress(Context context) {
    if (location != null) {
        Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);
        try {
            return geocoder.getFromLocation(latitude, longitude, 1);
        } catch (IOException e) {
            //e.printStackTrace();
            Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e);
        }
    }

    return null;
}

public String getAddressLine(Context context) {
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        return address.getAddressLine(0);
    } else {
        return null;
    }
}

public String getLocality(Context context) {
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        return address.getLocality();
    } else {
        return null;
    }
}

public String getSubLocality(Context context) {
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        return address.getSubLocality();
    } else {
        return null;
    }
}

public String getPostalCode(Context context) {
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        return address.getPostalCode();
    } else {
        return null;
    }
}

public String getCountryName(Context context) {
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0) {
        Address address = addresses.get(0);

        return address.getCountryName();
    } else {
        return null;
    }
}

@Override
public void onLocationChanged(Location location) {

    this.location = location;

}

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

}

@Override
public void onProviderDisabled(String provider) {
}

@Override
public void onProviderEnabled(String provider) {
}

@Override
public void onConnected(Bundle connectionHint) {
    isPlayServicesEnabled = true;
    getLocation();
}

@Override
public void onConnectionSuspended(int cause) {
    isPlayServicesEnabled = false;
}

@Nullable
@Override
public IBinder onBind(Intent intent) {
    return null;
}

}

这是我调用 AsyncTask 的地方:

public class Weather extends AppCompatActivity{

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.meteo_nuovo);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_layout);
    setSupportActionBar(toolbar);

    toolbar.setPadding(0, getStatusBarHeight(), 0, 0);

    assert getSupportActionBar() != null;

    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);    
    this.getSupportActionBar().setDisplayShowTitleEnabled(false);  

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }

    new WeatherApi(this).execute();  // the doInBackground method above is from this class

}

public int getStatusBarHeight() {
    int result = 0;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = getResources().getDimensionPixelSize(resourceId);
        }
    }
    return result;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

}

使用 getLastKnownLocation 有时会导致问题,因为它可能需要一些时间才能真正找到 lastKnownLocation。

尝试使用 onLocationChanged 函数设置您的位置,这应该可以有效地解决这个问题。

您可以按如下方式进行:

@Override
public void onLocationChanged(Location location)
{
    this.location = location;
}

现在,每次更改(或首次找到)您的位置时,都会调用 onLocationChanged 事件并将您的 GPSTracker 位置变量设置为调用参数中传递的位置!

编辑:

尝试将您的 GPSTracker class 更改为以下内容:

public class GPSTracker extends Service implements LocationListener, ConnectionCallbacks {
private final Context mContext;

boolean isPlayServicesEnabled = false;

boolean isGPSEnabled = false;

boolean isNetworkEnabled = false;

boolean canGetLocation = false;

Location location;
double latitude;
double longitude;

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; //10 meters

private static final long MIN_TIME_BW_UPDATES = 1000 * 60; // 1 minute

protected LocationManager locationManager;

public GPSTracker(Context context) {
    this.mContext = context;
}

public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);

        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
        } else {
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this, Looper.getMainLooper());

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

                if (locationManager != null) {
                    location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    updateGPSCoordinates();
                }
            }
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                    Log.d("GPS Enabled", "GPS Enabled");

                    if (locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        updateGPSCoordinates();
                    }
                }
            }
        }
    } catch (Exception e) {
        //e.printStackTrace();
        Log.e("Error : Location", "Impossible to connect to LocationManager", e);
    }

    return location;
}

public void updateGPSCoordinates() {
    if (location != null) {
        latitude = location.getLatitude();
        longitude = location.getLongitude();
    }
}

public void stopUsingGPS() {
    if (locationManager != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    public void requestPermissions(@NonNull String[] permissions, int requestCode)
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for Activity#requestPermissions for more details.
                return;
            }
        }
        locationManager.removeUpdates(GPSTracker.this);
    }
}

public double getLatitude()
{
    if (location != null)
    {
        latitude = location.getLatitude();
    }

    return latitude;
}

public double getLongitude()
{
    if (location != null)
    {
        longitude = location.getLongitude();
    }

    return longitude;
}

public boolean canGetLocation()
{
    return this.canGetLocation;
}

public List<Address> getGeocoderAddress(Context context)
{
    if (location != null)
    {
        Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);
        try
        {
            return geocoder.getFromLocation(latitude, longitude, 1);
        }
        catch (IOException e)
        {
            //e.printStackTrace();
            Log.e("Error : Geocoder", "Impossible to connect to Geocoder", e);
        }
    }

    return null;
}

public String getAddressLine(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);

        return address.getAddressLine(0);
    }
    else
    {
        return null;
    }
}

public String getLocality(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);

        return address.getLocality();
    }
    else
    {
        return null;
    }
}

public String getSubLocality(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);

        return address.getSubLocality();
    }
    else
    {
        return null;
    }
}

public String getPostalCode(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);

        return address.getPostalCode();
    }
    else
    {
        return null;
    }
}

public String getCountryName(Context context)
{
    List<Address> addresses = getGeocoderAddress(context);
    if (addresses != null && addresses.size() > 0)
    {
        Address address = addresses.get(0);

        return address.getCountryName();
    }
    else
    {
        return null;
    }
}

@Override
public void onLocationChanged(Location location)
{
}

@Override
public void onProviderDisabled(String provider)
{
}

@Override
public void onProviderEnabled(String provider)
{
}

@Override
public void onConnected(Bundle connectionHint) {
    isPlayServicesEnabled = true;
    getLocation();
}

@Override
public void onConnectionSuspended(int cause) {
    isPlayServicesEnabled = false;
}

我认为可能导致您出现问题的原因是您没有检查 Google Play 服务是否已连接。在上面的代码中,我实现了 ConnectionCallbacks 并包含了 onConnected 和 onConnectionSuspended 覆盖。现在,getLocation() 只会在 Play 服务连接后被调用。让我知道这是否有效。

我假设您正在 activity 的 onCreate() 方法中调用 doInBackground() 方法,因此如果 GPS 未启用,那么您的应用程序将被重定向到 GPS 设置屏幕。

因此,当您在启用它后从 GPS 设置屏幕返回时,您的 Activity 恢复,因此它不会再次调用 doInBackground(),这就是您没有得到任何结果的原因。

最简单的解决方案是为您的 Activity 定义 onResume() 方法并在 onResume() 中调用 doInBackground() 而不是 onCreate() 所以当您的 Activity resume 所以它会再次调用 doInBackground() 你得到更新的结果。

您应该像这样更新您的是否 Activity:

public class Weather extends AppCompatActivity{

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.meteo_nuovo);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_layout);
    setSupportActionBar(toolbar);

    toolbar.setPadding(0, getStatusBarHeight(), 0, 0);

    assert getSupportActionBar() != null;

    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);    
    this.getSupportActionBar().setDisplayShowTitleEnabled(false);  

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }  
}

@Override
public void onResume(){
    super.onResume();
   new WeatherApi(this).execute();  // the doInBackground method above is from this class

}

public int getStatusBarHeight() {
    int result = 0;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = getResources().getDimensionPixelSize(resourceId);
        }
    }
    return result;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
}

希望对你有所帮助

据我所知,我遇到过这个问题,但我已经用自己的方式解决了。

在你的 GPSTracker class 中创建一个方法。

public void onActivityResult(int requestCode, int resultcode, Intent data) {

}

现在用 startActivityForResult 开始 activity,而不是 startActivity

Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivityForResult(intent, 0);

当您返回 onActivityResult 方法时,现在在您的 activity 中

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    gpsTracker.onActivityResult(requestCode, resultCode, data);// This line is more important 

    if (requestCode == 0) {

        handler.sendEmptyMessage(0);

    }
}

现在 handler

android.os.Handler handler = new android.os.Handler(new android.os.Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        try {
              Location location = gpsTracker.getLocation();
              latitude = location.getLatitude();
              longitude = location.getLongitude();
        } catch (Exception e) {
            Log.v("Error:", "Location is null");
        }
        return false;
    }
});

使用它,您可以像我得到的那样立即定位。可能会有帮助。就我而言,它工作正常。