Search code examples
androidandroid-fragmentsandroid-studiogoogle-play-servicesandroid-fragmentactivity

Connecting to Google Play game services for all activities within a project


Based on the Google Play game services samples, particularly TypeANumber, from (https://github.com/playgameservices/android-basic-samples), I was wondering if it's preferred to implement all of the activities as fragments (other than MainActivity that's responsible for instantiating and connecting to GoogleApiClient) if I wanted my app to be connected to the services the whole time.

Because, I already developed a game app that consists of activities that transitions to each other by using using Bundles and Intents, and now I am just starting to figure out how to implement Google Play game services to my game. I already read the tutorials and whatnot, but I just want to know if it's recommended to use fragments for the other activities.


Solution

  • In other words, you're pretty much just asking which is better to use between Activity and Fragment. It technically still depends on you are aiming for. Looked around the community for a while and found these posts where the answers are very much detailed:

    Dilemma: when to use Fragments vs Activities:

    Why fragments, and when to use fragments instead of activities?

    On a simpler note, I prefer to use Fragment when re-usability is needed.