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

Ale*_*lex 2 android facebook invite android-contacts

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

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

Bar*_*man 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);   
Run Code Online (Sandbox Code Playgroud)

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

    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "http://www.yourdomain.com");
Run Code Online (Sandbox Code Playgroud)

如果要共享其他文本(如上例所示),则必须为Facebook创建单独的共享功能.

巴里