我遇到了 GooglePlayServiceUtil 的问题,一些设备安装了 9.0.83 的 google play 服务。 我在具有播放服务版本 8.7.03 的设备中检查了相同的内容,并且我收到了法律声明。
下面是我用来获取法律声明的代码。
TextView tv = (TextView) findViewById(R.id.notice);
if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS) {
Toast.makeText(this, "ConnectionResult.SUCCESS", Toast.LENGTH_LONG).show();
tv.setText(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this));
}else if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) == ConnectionResult.SERVICE_MISSING){
Toast.makeText(this, "ConnectionResult.SERVICE_MISSING", Toast.LENGTH_LONG).show();
}else if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) == ConnectionResult.SERVICE_DISABLED){
Toast.makeText(this, "ConnectionResult.SERVICE_DISABLED", Toast.LENGTH_LONG).show();
}
GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this)
为版本 9.0.83 返回 null。但它返回版本 8.7.03 和 7.x.x 设备的法律声明字符串。
我也试过
GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(Context)
但结果与 GooglePlayServicesUtil 相同。 如果有人可以指导我获得正确的结果,那将会很有帮助。
最佳答案
我遇到了同样的问题,在升级 Google Play 服务(撰写此答案时为 9.0.0)、重建项目并重新安装应用程序后,我开始正确获取许可证。
我正在使用 GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(this);
关于Android GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this) 在谷歌播放服务版本 9.0.83 上返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37347451/