如果我的 Android 设备没有 Google Play 服务,如何添加 Google 云端硬盘帐户

How to add Google Drive account if my Android device doesn't have Google Play Service

我正在编写一个 Android 应用程序,如果我的 Android 设备没有 Google Play 服务,我该如何添加 Google Drive 帐户,一些设备在他们的系统中没有 Google Play 服务,我检查了 google Android 和 REST API 的驱动 sdk,它们都依赖于 Google Play获取 Google 帐户的服务。 https://developers.google.com/drive/android/intro https://developers.google.com/drive/web/quickstart/android 有一个OfficeSuite应用程序,如果当前设备有Google Play服务,它使用上面的SDK获取Google帐户,否则,它会显示一个Google认证页面来获取Google帐户。我检查了 google drive sdk,但是我没有找到 Android 的功能,所以谁知道我该怎么做?

来自 Google Play 服务的功能对您的应用来说是必不可少的,否则您的应用将无法运行。

您可以使用 GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context) 检查您的应用程序中是否启用了这些服务 returns ConnectionResult.SUCCESS 如果 Play 服务可用。

由于 Google Play 服务不是清单中声明的​​功能,您的应用应该可以在任何设备上正常安装,但如果您在使用 API 时未检查它们是否可用,则稍后可能会崩溃。

但是如果用户没有在您的应用程序中使用这段代码,您总是可以要求用户安装 Google Play 服务。

public OnClickListener getGooglePlayServicesListener()
{
    return new OnClickListener() 
    {
        @Override
        public void onClick(DialogInterface dialog, int which) 
        {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.gms"));
            startActivity(intent);

            //Finish the activity so they can't circumvent the check
            finish();
        }
    };

找到了,请参考http://www.learn2crack.com/2014/01/android-oauth2-webview.html http://ddewaele.github.io/AndroidOauth2GoogleApiJavaClient/ 我试过了,可以的。