Android错误获取位置

时间:2018-06-30 23:35:15

标签: java android locationmanager

你好,我想获取位置,但未加载。

我的班次关于装载位置:

public class GetGPCAdress implements LocationListener {

Activity activity;
GetAdress getAdress;

public GetGPCAdress(Activity activity, GetAdress getAdress) {
    this.activity = activity;
    this.getAdress = getAdress;
    try {
        LocationManager locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 5, this);
    }
    catch(SecurityException e) {
        e.printStackTrace();
    }
}

@Override
public void onLocationChanged(Location location) {
    getAdress.get_gpc_address(location.getLatitude(), location.getLongitude());
}

....

我从活动中运行它

private void load_locatio () {

        Log.d("NekTest", "StartLoadLocation");

        new GetGPCAdress(activity, new GetGPCAdress.GetAdress() {
            @Override
            public void get_gpc_address(Double lat, Double log) {
                my_latitude = lat;
                my_logtitude = log;

                Log.d("NekTest", "AddressTook");

                open_dialog();
            }

            @Override
            public void get_full_address(String address) {
                full_address = address;
            }
        });

    }

我授予了所有权限并在运行前检查了权限 并在清单文件中写入了权限。

0 个答案:

没有答案