android - Android 中的 Google+ : installing app when sharing

标签 android api android-intent google-plus sharing

我试图让我的应用程序在 Google+ 中共享某些代码,并且当用户安装了官方 Google+ 应用程序时它可以正常工作。 然而,当它没有安装时,根据文档,应该有一个弹出窗口告诉用户他/她没有安装该应用程序,当点击按钮时,该应用程序应该被重定向到 Google Play 以便下载它.. 但是当点击按钮时,没有任何反应。

有什么想法吗? 这是我的按钮代码:

plus.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                shareDialog.dismiss();
                // Launch the Google+ share dialog with attribution to your app.
                Intent shareIntent = ShareCompat.IntentBuilder.from(getActivity()).setType("text/plain").setText("Welcome to the Google+ platform. https://developers.google.com/+").getIntent()
                        .setPackage("com.google.android.apps.plus");

                int errorCode = GooglePlusUtil.checkGooglePlusApp(getActivity());
                if (errorCode != GooglePlusUtil.SUCCESS) {
                    GooglePlusUtil.getErrorDialog(errorCode, getActivity(), 1).show();
                } else {
                    startActivity(shareIntent);
                }
            }
        });

提前致谢!

最佳答案

新手错误:使用 GooglePlusUtil.getErrorDialog(errorCode, getActivity(), GooglePlusUtil.APP_MISSING) 而不是 GooglePlusUtil.getErrorDialog(errorCode, getActivity(), 1).show(); .show();

关于android - Android 中的 Google+ : installing app when sharing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14347475/

相关文章:

android - Kotlin DataBinding : IncompleteAnnotationException: android. databinding.BindingBuildInfo 缺少元素

java - 使用软件包名称中的大写字母构建Cordova Android项目时出错

android - Facebook 从我的 android 应用程序上传对话框

javascript - 没有 JSON 根的 Ember.js REST 适配器

android - 使用 ACTION_VIEW Intent Action 启动文件

android - Intent.EXTRA_CC 不适用于 Android 的 GMail 4.2.1

Android Intent 打开图库在 KitKat (4.4) 上不起作用

android - 用于备份和恢复 Android 应用程序的数据库和共享首选项的 Google Drive

javascript - 在 Cypress 中多次拦截同一个 API 调用

java - 如何用 Java 编写 Facebook 应用程序?