初始化LocationCallback时出现UnsupportedOperationException

时间:2018-11-28 03:45:15

标签: java android android-studio location android-location

最近,我正在使用GPS位置API,我试图获取当前更新的GPS位置,但是在初始化LocationCallback()时,出现了此错误:

java.lang.UnsupportedOperationException: can't load this type of class file

以下部分中的代码段尝试获取LocationCallback():

private void createLocationCallback() {
    mLocationCallback = new LocationCallback() {
        @Override
        public void onLocationResult(LocationResult locationResult) {
            super.onLocationResult(locationResult);
            mCurrentLocation = locationResult.getLastLocation();
            setLatLong(mCurrentLocation);
        }
    };
}

谈到:

mLocationCallback = new LocationCallback()

它向我返回错误。

经过几天的挣扎,我发现了自己:

LocationCallBack();

源代码为空:

package com.google.android.gms.location;

public class LocationCallback {
    public LocationCallback() {
    }

    public void onLocationResult(LocationResult var1) {
    }

    public void onLocationAvailability(LocationAvailability var1) {
    }
}

我怀疑这是错误的根本原因。 如果有人可以帮助我,我将不胜感激。

0 个答案:

没有答案