question

Narasimha avatar image
Narasimha asked

gamecircle

Hi, we want to add game circle for our games,can u provide sample application for the Game Circle.
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 Dumadu, There is no sample application available at this moment. But you should be able to find sample code snippets for all our GameCircle features (Leader board, Achievements, Whispersync) in our GameCircle documentation page. Please refer below links for detail. https://developer.amazon.com/sdk/gamecircle.html https://developer.amazon.com/sdk/gamecircle/documentation/leaderboards.html https://developer.amazon.com/sdk/gamecircle/documentation/achievements.html https://developer.amazon.com/sdk/gamecircle/documentation/whispersync.html Hope this helps.
10 |5000

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

Narasimha avatar image
Narasimha answered
i have done all the process and added the code like below but i didn,t get and the app getting force close once check and give the solution import java.util.EnumSet; import com.amazon.ags.api.AGResponseCallback; import com.amazon.ags.api.AGResponseHandle; import com.amazon.ags.api.AmazonGames; import com.amazon.ags.api.AmazonGamesCallback; import com.amazon.ags.api.AmazonGamesClient; import com.amazon.ags.api.AmazonGamesFeature; import com.amazon.ags.api.AmazonGamesStatus; import com.amazon.ags.api.achievements.AchievementsClient; import com.amazon.ags.api.achievements.UpdateProgressResponse; import com.amazon.ags.api.leaderboards.LeaderboardsClient; import com.amazon.ags.api.leaderboards.SubmitScoreResponse; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { Button button; Button btnLeaderboardsOverlay; // TODO Auto-generated method stub // We'll initialize this once the application has launched. AmazonGames agsGameClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.LBbutton); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub EnumSet agsGameFeatures = EnumSet.of( AmazonGamesFeature.Achievements, AmazonGamesFeature.Leaderboards); // Create a callback to handle initialization result codes. AmazonGamesCallback agsGameCallback = new AmazonGamesCallback() { @Override public void onServiceReady() { } @Override public void onServiceNotReady(AmazonGamesStatus reason) { switch (reason) { case CANNOT_AUTHORIZE: /** * The service could not authorize the client. This should only * occur if the network is not available the first time the game * attempts to connect. */ case CANNOT_BIND: /** *The service could not bind either because it does not exist, * or permissions have not been granted. This will also occur * when your game is executed on a non-fire device that does not * have Amazon GameCircle installed. */ case NOT_AUTHENTICATED: /** * The device is not registered with an account. * Disable Amazon GameCircle features in Game UI. */ case NOT_AUTHORIZED: /** * The game in not authorized to use the service. Check your * package name and signature registered in the Developer's * Portal. */ case SERVICE_NOT_OPTED_IN: /** * The device is not opted-in to use the service. */ break; default: break; } } }; // Intent intent = new Intent(MainActivity.this,AmezonCircle.class); // Initialize Amazon GameCircle. agsGameClient = AmazonGamesClient.initialize( getApplication(), agsGameCallback, agsGameFeatures); } }); LeaderboardsClient lbClient = agsGameClient.getLeaderboardsClient(); AGResponseHandle handle = lbClient.submitScore("12345",100); // Optional callback to receive notification of success/failure. handle.setCallback(new AGResponseCallback () { @Override public void onComplete(SubmitScoreResponse result) { if (result.isError()) { // Add optional error handling here. Not strictly required // since retries and on-device request caching are automatic. } else { // Continue game flow. } } }); AmazonGames agsClient = null; @SuppressWarnings("null") AchievementsClient acClient = agsClient.getAchievementsClient(); AGResponseHandle handle1 = acClient.updateProgress("001", 100.0f); // Optional callback to receive notification of success/failure. handle1.setCallback(new AGResponseCallback () { @Override public void onComplete(UpdateProgressResponse result) { if (result.isError()) { // Add optional error handling here. Not strictly required // since retries and on-device request caching are automatic. } else { // Continue game flow. } } }); } }
10 |5000

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

Narasimha avatar image
Narasimha answered
thanks Message was edited by: dumadu
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 Dumadu, Could you post back the exception stack trace which appears in ADB logcat while the app gets crashed? Also, In order to get GameCircle working in sandbox environment, you have to do few things. 1. Authenticate your game with Amazon GameCircle: Related document: https://developer.amazon.com/sdk/gamecircle/documentation/gamecircle-setup.html#Section3 2. Add test nick name: Related document: https://developer.amazon.com/sdk/gamecircle/documentation/gamecircle-setup.html#Section4 Please check once that you have gone through these steps. The main problem I can see in your code is calls on AmazonGames instance is in wrong place. Also this can be the problem, AmazonGames agsClient = null; AchievementsClient acClient = agsClient.getAchievementsClient(); agsClient is null and you trying to call getAchievementsClient on that. So NullPointerException must be coming in runtime. Please have a look on the below code. I have tried to handle the asynchronous calls on GameCircle SDK calsses and summit an achievement. import android.app.Activity; import android.os.Bundle; import android.view.View; import java.util.EnumSet; import com.amazon.ags.api.*; import com.amazon.ags.api.achievements.AchievementsClient; import com.amazon.ags.api.achievements.UpdateProgressResponse; public class MyActivity extends Activity { /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } // We'll initialize this once the application has launched. AmazonGames agsGameClient; // Make a list of the Amazon GameCircle features your game uses. // Only show the features you are using. EnumSet agsGameFeatures = EnumSet.of( AmazonGamesFeature.Achievements, AmazonGamesFeature.Whispersync, AmazonGamesFeature.Leaderboards); // Create a callback to handle initialization result codes. AmazonGamesCallback agsGameCallback = new AmazonGamesCallback() { @Override public void onServiceReady() { System.out.println("MyActivity.onServiceReady"); AchievementsClient acClient = agsGameClient.getAchievementsClient(); AGResponseHandle handle1 = acClient.updateProgress("001", 100.0f); // Optional callback to receive notification of success/failure. handle1.setCallback(new AGResponseCallback () { @Override public void onComplete(UpdateProgressResponse result) { if (result.isError()) { // Add optional error handling here. Not strictly required // since retries and on-device request caching are automatic. } else { // Continue game flow. } } }); } @Override public void onServiceNotReady(AmazonGamesStatus reason) { System.out.println("reason = " + reason); switch (reason) { case CANNOT_AUTHORIZE: /** * The service could not authorize the client. This should only * occur if the network is not available the first time the game * attempts to connect. */ case CANNOT_BIND: /** *The service could not bind either because it does not exist, * or permissions have not been granted. This will also occur * when your game is executed on a non-fire device that does not * have Amazon GameCircle installed. */ case NOT_AUTHENTICATED: /** * The device is not registered with an account. */ case NOT_AUTHORIZED: /** * The game in not authorized to use the service. Check your * package name and signature registered in the Developer's * Portal. */ case SERVICE_NOT_OPTED_IN: /** * The device is not opted-in to use the service. */ break; default: break; } } }; public void submitAchievement(View view){ agsGameClient = AmazonGamesClient.initialize( getApplication(), agsGameCallback, agsGameFeatures); } } Hope this helps.
10 |5000

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