2

So I'm builing an Android social game.

What's the best strategy to get the user invite his friends in the game ? How to mix facebook connect, SMS, emails from the contact list ? What application does this perfectly in the minimum amount of steps.

Alex
  • 538
  • 1
  • 8
  • 18
  • Allow the app to send the game download link via SMS, Facebook post, Twitter, etc... Maybe offer something for each friend who joins via the link. Like in-game items – Spidy Jun 26 '11 at 00:02
  • But how to know if they came in the game after being invited ? – Alex Jun 26 '11 at 01:38

1 Answers1

13

Try using the ACTION_SEND intent, like this:

    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);   

This code will present a menu with all the applications that can send messages, including Facebook, Twitter, SMS, email, ...etc. The only limitation is that you can only share links with Facebook, so EXTRA_SUBJECT must be a pure URL or the user will get an error if they choose Facebook. In other words only this will work with Facebook:

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

If you want to share other text (like in the example above) you must create a separate share function for Facebook.

Barry

Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135
  • Great. And is there a way to know what/how many friends the user invited on the activity result ? – Alex Jun 26 '11 at 00:31
  • 1
    Sorry, not that I'm aware of. If you're happy with my answer above can you please vote for it and check it as the correct answer as that is the etiquette on this website. Thanks. – Barry Fruitman Jun 26 '11 at 14:00