[英]How to check version of google play services in firebase app
我的應用使用Firebase身份驗證和數據庫。 每當具有較低Google Play服務版本的手機使用該應用程序時......該功能不起作用,並且它不會告訴用戶該版本太低而且應該更新,但它會記錄到logcat。 所以我的問題是:我是否手動顯示警告或者firebase是否可以為我執行此操作? 如果我必須手動完成,怎么做?
在應用初始化期間,您的代碼應調用GoogleApiAvailability.makeGooglePlayServicesAvailable()。 在主Activity的onCreate()中使用示例:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "onComplete: Play Services OKAY");
} else {
// Show the user some UI explaining that the needed version
// of Play Services could not be installed and the app can't run.
}
}
});
...
}
用於手動檢查Google Play服務版本; 你可以在下面使用;
int gpsVersion = getPackageManager().getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0).versionCode;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.