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