我正在开发在Fragment中使用MessageDialog类的Android应用。如果用户按下BUTTON并且没有安装Messenger,则会提示他/她在Google Play安装它。安装完成后,我希望再次单击BUTTON以成功打开MessageDialog。但是, canShow()条件总是 false 。我必须重启我的应用程序才能正常工作。这有什么解决方法吗?
ShareLinkContent content = ...
MessageDialog dialog = new MessageDialog(this);
if (dialog.canShow(content)) {
// Open Messenger dialog
dialog.show(content);
} else {
// Messenger not installed
try {
// Prompt to install Messenger at Play Store
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=com.facebook.orca")));
} catch (android.content.ActivityNotFoundException e) {
// Google Play Services not installed
// See and prompt to install Messenger at available web app
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=com.facebook.orca")));
}
}
使用Facebook SDK版本4.6.0