By: James | August 10, 2015

Background

Part of the work I have been doing lately is creating custom pages for the pages in Google Play Games. This includes the Achievements, Leaderboards, Load Game, Player Se, Player Selection, etc. The plan is to create them with the same look and theme of my apps but maintain rough feature equivalence. It was going fairly well until it came down to a feature of the Leaderboards viewer. There was a simple button to let you compare your profile with that of another player. I found no documentation whatsoever regarding how to build an intent to do this.

Investigation

My initial search found this question on Stack Overflow. It wasn't exactly what I was asking for but it was close. Of course there was no answer. I eventually gave up my online search and went a bit more technical.


The first step was to look at the logcat when launching the intent from the Google version of the leaderboards page. That gives me this


{act=com.google.android.gms.games.destination.API_ACTIVITY flg="0x10008000" cmp="com.google.android.play.games/com.google.android.gms.games.ui.destination.api.ApiActivity" (has extras)}


Which then launches


{act=com.google.android.gms.games.destination.VIEW_PROFILE_COMPARISON flg="0x50000000" cmp="com.google.android.play.games/com.google.android.gms.games.ui.destination.players.PlayerDetailActivity" (has extras)}


So now I had the proper activity within Google Play Games to launch. I again tried some online searching about it and came up with nothing. I finally took a more drastic approach and ran a decompiler on the app itself to see if I could find anything and find something I did. I found how to deep link into Google Play Games to pretty much any useful page. There was essentially a big switch statement for all the different pages. I walked through each one and wrote out my code for them all. The game about page, achievements, leaderboards, specific leaderboard, players, quests, profile, profile compare, and inbox.


Results

View Gist on Github


The code in the gist is a working example of how to launch any page. There are "Magic" numbers that I found in the source code for each page. I tested across several versions of Google Play Games and they all work the same so hopefully they won't change. I did not find where they are defined.


To use just build an intent with buildDeepLinkIntent and then pass that intent to any of the page builders such as intentAbout and finally start it with startGooglePlayGames


Note that you may need to add in some additional error handling. This is an example only.

Comments:

Be the first to comment ...

Post a Comment