Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 48

krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
10/18/14 01:41 PM (9 years ago)

Android Leaderboard Integration

I've been working on a leaderboard solution for a quiz app which uses the free interactive quiz plug-in. I contacted a company called GameSparks to see if they could help integrate their leaderboard solution into a BT app. They've been really great and we are about 90% of the way there, but are now in need of BT community help to jump the final hurdle. I have added their jar file and GameSparks have provided a new .java file called "BT_gamesparks" which I've added to the BT project (like a custom plug-in). Follow this link to view it: https://www.dropbox.com/s/ttcywq99qmi0qi0/BT_gamesparks.java?dl=0 I'm now stuck. In the BT_screen_quiz.java file I need to call the postScore method contained in the BT_gamesparks.java file and pass in the totalScore value from the quiz. This is the postScore method: public void postScore(int value){ Map<String, Object> apiParamData = new HashMap<String, Object>(); apiParamData.put("@class", ".LogEventRequest"); apiParamData.put("eventKey", "SCORE_EVT"); apiParamData.put("SUB_SCR", value); GameSparksAndroidApi.getInstance().getSender(apiParamData).send(); } Any help would be really appreciated and I'd be happy to create a HOW TO doc if we can solve the problem.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/18/14 03:08 PM (9 years ago)
I'm just guessing, but you'll want to investigate calling that postScore method from within BT_screen_quiz.java I'd check out the 'endQuiz' method (around line 1119) and place 'your' method call near line 1159, where it checks for the 'send results to URL' instruction. ... ... if(sendResultsToURL.length() > 1){ sendQuizResultsToURL(); } // postScore(totalScore); //show finished options, this method also plays possible sound effects... showFinishedOptions(); ... ... and see how that works. "add" your custom class the same way you'd add other files and make sure the project 'knows' it is there. Cheers! -- Smug
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
10/18/14 03:22 PM (9 years ago)
Hi Smug That was my first thought too. but when I add: // postScore(totalScore); I get the red error "The method postScore(int) is undefined for the type BT_screen_quiz" which I guess relates to your point of "make sure the project 'knows' it is there". How do I get the BT_screen_quiz to know the method exists in the BT_gamesparks file? I have looked at how BT_screen_quiz uses BT_activity_host in the same way, but can't seem to replicate this.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/18/14 03:34 PM (9 years ago)
I'd have to dig deeper, but you might try something like: 1) declare a property that consists of your new class: public BT_gameSparks myGameSpark; 2) Then, down in the 'endQuiz' method try something like myGameSpark = new BT_gameSparks(this.getActivity()); myGameSpark.postScore(totalScore); I may not be completely accurate with regard to syntax, but I know that's the right path to investigate. Cheers! -- Smug
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
10/18/14 04:07 PM (9 years ago)
Eclipse likes your first and third lines, but on the second line: myGameSpark = new BT_gamesparks(this.getActivity()); it gives a red error "The constructor BT_gamesparks(Activity) is undefined" and it suggests altering the constructor in BT_gamesparks. //Private constructor, called by init. private BT_gamesparks(Application context){ context.registerActivityLifecycleCallbacks(new GameSparks_ActivityLifecycleCallbacks()); } or adding a new constructor. Neither of which I can get to work.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.