繁体   English   中英

如何在firebase应用中查看google play服务的版本

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM