Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

Firemonkey

Leaderboards And Achievements With Google Play Game Services In Delphi XE5 XE6 XE7 Firemonkey On Android

Delphi XE6 Firemonkey Google Play Game Services JAR APIDeveloper Pham Dinh Hai from DeuxSoftware has published a wrapper for the Google Play Game Services API on Android for Delphi XE6 (and XE7) Firemonkey. The wrapper gives you access to the Leaderboard and Achievement services provided by Google. The developer originally built this code for his Delphi Firemonkey game which is called Rolling Sheep. You can see screenshots of the leaderboards and achievements on his game page. In any event he translated the JNI code by hand and is provided the full source for the Game Services wrapper for free. It has a helper JAR file called basegameutils.jar which then utilizes the google-play-services.jar. Now it does require that you modify the classes.dex file to get access to the Game Services. There is an included bat file and readme instructions which will help you compile your own classes.dex file for Delphi XE5 and Delphi XE6. In Delphi XE7 and Appmethod I think you can skip that step and add the JAR files directly to the Android Library section in your project. Here is a sample JNI class from the source code:
[JavaSignature('com/google/example/games/basegameutils/GameHelper')]
JGameHelper = interface(JObject)
['{DC334E08-C537-4900-8333-4E882BCEA010}']
{Methods}
procedure setup(listener:JGameHelper_GameHelperListener);cdecl;
procedure onStart(ac:JActivity);cdecl;
procedure onStop();cdecl;
function isSignedIn:boolean;cdecl;
function getApiClient:JGoogleApiClient;
procedure submitScore(LBid:JString;score:int64);cdecl;
function GetLeaderboardIntent(LBid:JString):Jintent;
function getAchievementsIntent():Jintent;
procedure UnlockAchievement(Aid:JString);cdecl;
procedure loadScoreOfLeaderBoard(LBid:JString);cdecl;
procedure enableDebugLog(enabled:boolean);cdecl;
procedure onActivityResult(requestCode:integer; resultCode:integer; data:JIntent);cdecl;
end;
TJGameHelper = class(TJavaGenericImport) end;

Check out the full post about the Google Play Game Services wrapper on Google Plus before downloading the source code.

Mirror: Download the Google Play Game Services JNI wrapper for Delphi XE5 XE6 XE7 Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLibraryShowcaseWindows

Run Large Language Models Natively In Object Pascal

ComponentDelphiFiremonkeyIOSLinuxOSXWindows

Build Modern ChatGPT-Style AI Interfaces In FireMonkey

ComponentDelphiFiremonkeyUtilityWindows

Bring OpenClaw-Style AI Agents To Delphi And Object Pascal

C++BuilderDelphiFiremonkeyIDEUtility

Build And Design Delphi FireMonkey Apps With AI Inside RAD Studio

Sign up for our Newsletter and
stay informed
[mailpoet_form id="1"]

Leave a Reply