首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >GoogleAPIClient已弃用-如何实现新的GoogleSignInOptions?

GoogleAPIClient已弃用-如何实现新的GoogleSignInOptions?
EN

Stack Overflow用户
提问于 2021-01-09 23:33:45
回答 1查看 1.1K关注 0票数 2

我正在做一个YouTube教程(https://www.youtube.com/watch?v=gAIErOevfoA),我已经让我的地图工作得很好,但是它没有显示附近的位置。我注意到有一行通过GoogleApiClient,并被告知它现在已更改为GoogleSignInOptions

我是Android Studio的新手,所以我不知道如何在这段代码中实现新的方式。我试着把GoogleApiClient改成GoogleSignInOptions,但是现在得到了更多的错误,我不想弄乱我已经有的东西。

这是包含错误的Java文件,我将其缩短了一点,在if语句中还发现了一个错误- if (mGoogleApiClient.isConnected()) {...}

代码语言:javascript
运行
复制
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();
    }
}
EN

回答 1

Stack Overflow用户

发布于 2021-01-09 23:39:51

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65644409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档