我正在做一个YouTube教程(https://www.youtube.com/watch?v=gAIErOevfoA),我已经让我的地图工作得很好,但是它没有显示附近的位置。我注意到有一行通过GoogleApiClient,并被告知它现在已更改为GoogleSignInOptions。
我是Android Studio的新手,所以我不知道如何在这段代码中实现新的方式。我试着把GoogleApiClient改成GoogleSignInOptions,但是现在得到了更多的错误,我不想弄乱我已经有的东西。
这是包含错误的Java文件,我将其缩短了一点,在if语句中还发现了一个错误- if (mGoogleApiClient.isConnected()) {...}
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,
        GoogleSignInOptions.OnConnectionFailedListener, LocationListener {
    private GoogleMap mMap;
    GoogleSignInOptions mGoogleApiClient;
    double currentLatitude, currentLongitude;
    Location myLocation;
    private final static int REQUEST_CHECK_SETTINGS_GPS = 0x1;
    private final static int REQUEST_ID_MULTIPLE_PERMISSIONS = 0x2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
        setUPGClient();
    }
    private void setUPGClient() {
        mGoogleApiClient = new GoogleSignInOptions.Builder(this)
                .enableAutoManage(this, 0, this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
        mGoogleApiClient.connect();
    }
}发布于 2021-01-09 23:39:51
https://stackoverflow.com/questions/65644409
复制相似问题