android – 没有Google Play服务的设备的后备计划是什么?

前端之家收集整理的这篇文章主要介绍了android – 没有Google Play服务的设备的后备计划是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
目前,我正在迁移以前的Google服务,这些服务将jar库用于Google Play服务.

> Google AdMob
> Google Analytics
> Google云端硬盘

但是,在迁移指南中,Google没有提及我们应该做什么,没有Google Play服务的设备,或者没有最新的Google Play服务.

那么,我们应该忽略没有Google Play服务的用户,还是有退回计划?

必须为后备计划维护单独的jar文件集和遗留代码是非常麻烦的.此外,可能存在冲突问题,并排有jar文件和GPS. Utilize both Play Services and AdMob SDK

解决方法

1.检查Google Play服务

here所述,您应始终确保:

> Google Play服务APK完全存在.
>安装了正确的版本.

大多数情况下,您将在onResume()方法中执行这些检查. GooglePlayServiceUtils有一个名为isGooglePlayServicesAvailable(…)的方法,用于检查Google Play服务是否已安装以及它们是否为正确版本.它返回一个int错误代码,告诉你大致错误

@Override
public void onResume() {
    super.onResume();

    int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
    switch(errorCode) {
        case ConnectionResult.SUCCESS:
            // Google Play Services installed and up to date
            break;

        case ConnectionResult.SERVICE_MISSING:
            // Google Play services is missing on this device.
            break;

        case ConnectionResult.SERVICE_VERSION_UPDATE_required:
            // The installed version of Google Play services is out of date.
            break;

        case ConnectionResult.SERVICE_DISABLED:
            // The installed version of Google Play services has been disabled on this device.
            break;

        case ConnectionResult.SERVICE_INVALID:
            // The version of the Google Play services installed on this device is not authentic.
            break;

        case ConnectionResult.DATE_INVALID:
            // The device date is likely set incorrectly.
            break;          
    }
}

您可以使用GooglePlayServiceUtils的showErrorDialogFragment(…)等方法显示相应的错误消息:

int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if(GooglePlayServiceUtil.showErrorDialogFragment(errorCode,getActivity(),REQUEST_CODE)) {
    // Dialog was shown
} else {
    // Dialog was not shown.
}

仅当错误代码不是ConnectionResult.SUCCESS时才会显示该对话框.

您可以找到GooglePlayServiceUtil类here的文档.

2.后退

您是否需要回退仅取决于您的应用和您所定位的市场.例如,如果您将其发布到Google Play商店 – 我假设您在使用Google Play服务后也这样做 – 那么您实际上并不需要回退.因为要让人们下载您的应用,他们首先需要Google Play商店,如果他们拥有Google Play商店,则他们需要访问Google Play服务.如果您想要为亚马逊设备或诺基亚商店发布它,那当然是完全不同的故事,因为那些设备没有Google Play商店或Google Play服务.同样在中国这样的市场中,几乎没有任何Android设备与谷歌Play商店或任何谷歌服务,所以基本上你必须决定你的应用是否有必要,但正如我所说,如果你把它发布到谷歌Play商店我不会不用担心.上面提到的检查和错误对话框应该足以确保您的应用程序正常运行.新版Google Play服务APK的推出通常非常快.可能需要几天时间,但之后大多数设备都收到了更新.您还必须考虑一件事:如果您开发的应用程序需要当前Google Play服务的功能,那么您很可能不会遇到任何问题,因为几乎所有设备都已经拥有当前版本,因此要相当困难.找到一个不是最新的设备.当您快速推出使用几天前推出的新功能的应用程序更新时,您必须要小心.在这种情况下,您可能会遇到更多问题.

但最后你必须记住,这一切都取决于你在你想要发布应用程序的生态系统中发布应用程序的国家/地区.

我希望我能回答你的问题,如果你有任何进一步的问题,请随时提出!

猜你在找的Android相关文章