2

所以我正在构建一个Android社交游戏。

让用户在游戏中邀请他的朋友的最佳策略是什么?如何混合使用联系人列表中的 facebook connect、SMS、电子邮件?什么应用程序可以在最少的步骤中完美地做到这一点。

4

1 回答 1

12

尝试使用 ACTION_SEND 意图,如下所示:

    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Try (your game) for Android!");
    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I'm using (your game) for Android and I recommend it. Click here: http://www.yourdomain.com");

    Intent chooserIntent = Intent.createChooser(shareIntent, "Share with");
    chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(chooserIntent);   

此代码将显示一个菜单,其中包含所有可以发送消息的应用程序,包括 Facebook、Twitter、SMS、电子邮件等。唯一的限制是您只能与 Facebook 共享链接,因此 EXTRA_SUBJECT 必须是纯 URL,否则如果用户选择 Facebook,则会收到错误消息。换句话说,只有这适用于 Facebook:

    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "http://www.yourdomain.com");

如果您想分享其他文本(如上例),您必须为 Facebook 创建单独的分享功能。

巴里

于 2011-06-26T00:05:03.310 回答