让用户在Android上邀请他的朋友的最佳策略?

时间:2011-06-25 23:57:06

标签: android facebook android-contacts invite

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

让用户邀请他的朋友加入游戏的最佳策略是什么? 如何混合来自联系人列表的Facebook连接,短信,电子邮件?什么应用程序在最少的步骤中完美地完成。

1 个答案:

答案 0 :(得分: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创建一个单独的共享功能。

百里