我正在尝试让我的应用在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);
}
}
});
提前多多感谢!
答案 0 :(得分:2)
新手错误:代替GooglePlusUtil.getErrorDialog(errorCode, getActivity(), 1).show();
使用GooglePlusUtil.getErrorDialog(errorCode, getActivity(), GooglePlusUtil.APP_MISSING).show();