question

Android avatar image
Android asked

Is initialize() *necessary*

In the API docs, it states for getWhispersyncClient(): Retrieves an instance of the WhispersyncClient. Unlike the other clients, WhispersyncClient can be used immediately after calling initialize(). My question is: given that this is a static method, is it even necessary to even call initialize() before you to start using WhisperSync? Obviously, I appreciate that it won't be able to sync with the cloud until after initialize() has been completed. As suggested, in onResume() I call: AmazonGamesClient.initialize(this, callback, myGameFeatures); and in onPause() I call: agsClient.release(); Am I right to believe that I can use WhisperSync regardless of the state of the agsClient?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Jonathan, Thank you for posting. Though getWhispersyncClient() is exposed as static function, still it do depends on the fact AmazonGamesClient to be initialized before. So until unless you are receiving the call back to onServiceReady() method of instance of AmazonGamesCallback passed to AmazonGamesClient.initialize(), you are not supposed to access the whisper sync client though the getter accessor of whispersyncClient (leaderboardClient and achievementClient too) is exposed as static. Don't forget that you have to mention AmazonGamesClient.initialize() what features have to be initialized in game circle client, I mean this EnumSet myGameFeatures = EnumSet.of( AmazonGamesFeature.Achievements, AmazonGamesFeature.Leaderboards, [b]AmazonGamesFeature.Whispersync[/b]); AmazonGamesClient.initialize(this, callback, [b]myGameFeatures[/b]); Hope this makes sense. I agree that there is no point having static methods to access whispersync, leaderboard and achievement clients and it creates confusion to developers unnecessarily. I am taking note and forwarding this valuable feedback to the concerned team. Thanks for bringing this into our notice.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Correction. The Whispersync client CAN be used IMMEDIATELY after calling initialize(). However, you still must call initialize() to pass an Android Context to GameCircle to allow it to access local storage. Unlike the Achievements and Leaderboards clients, you can start using the Whispersync client without waiting for the onServiceReady() callback. This will allow you to access the local copy of whispersync data just as you would SharedPreferences or a local file. When initialization is complete, and the player is online and registered, Whispersync will automatically start synchronizing with the cloud.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.