[英]Android Google Play services
我使用Google Play服务开发了一个Android应用,以使用GCM服务。
在MainActivity中,在访问Google Play服务功能之前,先检查设备是否有兼容的Google Play服务APK。 在应用程序中,此检查在两个地方完成:在主活动的onCreate()方法及其onResume()方法中。 像这样:
if (checkPlayServices()) {
// If this check succeeds, proceed with normal processing.
// Otherwise, prompt user to get valid Play Services APK.
...
}
和:
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
我的问题是:在某些国家/地区,用户无法从GooGlePlay下载Google Play服务,因此他们无法使用我的应用。
是否可以在应用程序上放置Google Play服务? 还是将其放在另一台服务器上并提示用户从新位置下载Google Play服务?
任何其他解决方案都欢迎。
最好的祝福,
即使有了Google Play服务库,您仍然需要将其安装在设备上。 GooglePlayServicesUtil
专门用于检查Google Play服务(如果已安装,版本等)。
呼叫isGooglePlayServicesAvailable()
来检查您是否安装了它,以及是否安装了什么版本。 如果resutCode 并不成功,然后调用GooglePlayServicesUtil.getErrorDialog()
并将它传递了错误代码。 这应该提示用户安装Google Play服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.