gpt4 book ai didi

java - 如何处理 GooglePlayServicesRepairableException 和 GooglePlayServicesNotAvailableException

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:53:41 27 4
gpt4 key购买 nike

我阅读了官方文档,这让我很困惑。有什么区别GooglePlayServicesRepairableExceptionGooglePlayServicesNotAvailableException。什么时候扔?如何处理这些错误?如何向用户显示一个对话框,他可以在其中启用/更新/安装服务。等等

private void startLocationPicker() {
try {
new PlacePicker.IntentBuilder().build(this);
} catch (GooglePlayServicesRepairableException e) {

} catch (GooglePlayServicesNotAvailableException e) {

}
}

最佳答案

GooglePlayServicesRepairableException docs 中所述:

GooglePlayServicesRepairableExceptions are special instances of UserRecoverableExceptions which are thrown when Google Play Services is not installed, up-to-date, or enabled. In these cases, client code can use getConnectionStatusCode() in conjunction with getErrorDialog(android.app.Activity, int, int) to provide users with a localized Dialog that will allow users to install, update, or otherwise enable Google Play services.

GooglePlayServicesNotAvailableException还有一个错误代码可以与 getErrorDialog() 一起使用,尽管我鼓励您查看 GoogleApiAvailability 中可用的所有方法。 .

关于java - 如何处理 GooglePlayServicesRepairableException 和 GooglePlayServicesNotAvailableException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37448163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com