Question

well , normally I want to submit value as a double to my leaderboard in google play service but it says submit method is for "long value"

Games.Leaderboards.submitScore 

void com.google.android.gms.games.leaderboard.Leaderboards.submitScore(GoogleApiClient arg0, String arg1, long arg2)

So how how can I submit double or float values?

Was it helpful?

Solution 2

For both a double and a float, you can just cast it over to a long like this:

long arg2 = (long) yourDoubleOrFloat; 

However, keep in mind that both a double and a float are unprecise, as they are floating point numbers. You may want to be using int's.

OTHER TIPS

See this documentation page:

void submitScore (GoogleApiClient apiClient, String leaderboardId, long score)

score has to be a of type long, but:

The meaning of the score value depends on the formatting of the leaderboard established in the developer console. Leaderboards support the following score formats:

  • Fixed-point: score represents a raw value, and will be formatted based on the number of decimal places configured. A score of 1000 would be formatted as 1000, 100.0, or 10.00 for 0, 1, or 2 decimal places.
  • Time: score represents an elapsed time in milliseconds. The value will be formatted as an appropriate time value.
  • Currency: score represents a value in micro units. For example, in USD, a score of 100 would display as $0.0001, while a score of 1000000 would display as $1.00

So you probably want to head over to the developer console and set your desired configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top