Hi guys,
I need to use 32 bit integers as a score. My workaround on iOS is to send a string as a score, and if it exists convert it to a 32 bit int. This works great. I'm trying to do the same on Android, but I think my complete lack of Java skillz is letting me down.
This is the current Java code for reportScore:
static public void reportScore(String id, long score, int immediate){
if(mHelper != null && mHelper.isSignedIn())
{
if(immediate == 1)
{
PendingResult<Leaderboards.SubmitScoreResult> result = Games.Leaderboards.submitScoreImmediate(mHelper.getApiClient(), id, score);
ResultCallback<Leaderboards.SubmitScoreResult> mResultCallback = new
ResultCallback<Leaderboards.SubmitScoreResult>() {
<a href="https://forum.gideros.rocks/profile/Override" rel="nofollow">@Override</a>
public void onResult(Leaderboards.SubmitScoreResult result) {
if (sData != 0)
{
if(result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK){
GGooglePlay.onScoreSubmitted(sData);
}
}
}
};
result.setResultCallback(mResultCallback);
}
else
{
Games.Leaderboards.submitScore(mHelper.getApiClient(), id, score);
}
}
} |
In order for this to be backwards compatible and accept a string as a score I've modified it, see code below. The app freezes and crashes when submitting any score (integer or string).
static public void reportScore(String id, long score, int immediate, String str_score){
if(mHelper != null && mHelper.isSignedIn())
{
if(str_score != null)
{
score = Long.valueOf(str_score);
}
if(immediate == 1)
{
PendingResult<Leaderboards.SubmitScoreResult> result = Games.Leaderboards.submitScoreImmediate(mHelper.getApiClient(), id, score);
ResultCallback<Leaderboards.SubmitScoreResult> mResultCallback = new
ResultCallback<Leaderboards.SubmitScoreResult>() {
<a href="https://forum.gideros.rocks/profile/Override" rel="nofollow">@Override</a>
public void onResult(Leaderboards.SubmitScoreResult result) {
if (sData != 0)
{
if(result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK){
GGooglePlay.onScoreSubmitted(sData);
}
}
}
};
result.setResultCallback(mResultCallback);
}
else
{
Games.Leaderboards.submitScore(mHelper.getApiClient(), id, score);
}
}
} |
Help!
Niclas
Comments
https://deluxepixel.com
So you would also need to change JNI code and recompile binaries. If you are up for it, I can specify where to change what, just let me know which plugin exactly are you using, cause I start to confuse them
You already commented on it.
https://deluxepixel.com
Likes: SinisterSoft
Using the files as is causes a crash, so I renamed the "libgsm.so" files to "libgoogleplay.so" (because the naming has changed, right?), but also crashes at start.
But as far as I remember, you just, from command line, cd in your plugins jni folder (where there are these sources and Andoird.mk and Application.mk) and run path/to/ndk-build
for Windows I use ndk-build.cmd, but I think osx/linux simply has nkd-build.
If you are using eclipse, you can setup ndk-build to build plugins on your app build:
http://mobilepearls.com/labs/ndk-builder-in-eclipse/
Have not used it in Android Studio though, but probably there should be a way to do it too.