如何解决GoogleAPIClient 已弃用 - 如何实施新的 GoogleSignInOptions?
我正在制作 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,this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
}
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。