Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

java - GoogleAPIClient Deprecated - How to Implement New GoogleSignInOptions?

I am working on a YouTube tutorial (https://www.youtube.com/watch?v=gAIErOevfoA), and I have gotten my map to work fine, however it is not showing the nearby locations. I noticed there was a line through GoogleApiClient and was told it has now changed to GoogleSignInOptions.

I'm fairly new to Android Studio, so I don't know really how to implement the new way into this code. I tried just changing GoogleApiClient to GoogleSignInOptions, but now getting more errors and I don't want to mess up what I have.

Here is the Java file with the errors, I have shorted this a bit, I am also getting one error further down on an if statement - 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();
    }
}
question from:https://stackoverflow.com/questions/65644409/googleapiclient-deprecated-how-to-implement-new-googlesigninoptions

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...