How to reset achievements in Google Play Games? - java

I made changes to the amount of XP which is gained by an achievement. Now I want to reset the achievements for users, so that their XP will be reset. It is currently too much. New achievements will reward the new XP, but the old XP is still visible in Google Play Games.
I tried to follow this guide for my developer account, and it didn't work:
https://developers.google.com/games/services/management/api/achievements/resetAll
It resulted in { instead of the result listed on the page.
Any ideas?

This feature seems to be available only for draft achievements.
See: https://developers.google.com/games/services/management/api/achievements

After a few tests, I realized a possible issue. First of all, there is a reset button on every achievement inside the developer console. You can just reset an achievement by pressing this button. But the following requirements must be fulfilled:
it has to be a release signed apk which is installed for testing.
The app must be in alpha or beta test phase, using the same version of app that you have installed for testing (not rellay sure about that)
The Play Games settings for your app shouldn´t be published. You can only reset achievements for test users with an unpublished game. With game I mean the play games settings, not the app itself.
After pressing the reset, it needs long time to reset, in my test it needed about 1 hour, but maybe could be longer or shorter.
But there is a little issue, I think it´s on Googles site and I reported it to Google. The reset doesn´t work on incremental achievements.

I was having issues with resetting and modifying draft achievements, no matter what changes I made to the Google Play Console the achievements on the Android client were never updated. Incremental achievements did not reset, adding achievements did not show up in client, etc.
However, I eventually discovered that running
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), REQUEST_ACHIEVEMENTS);
to display all achievement progress does seem to refresh the client properly. So now it works to reset and update achievements, as long as I start the achievements intent in the application afterwards.
Just adding this comment in case someone else runs into the same problem as me.
Edit: it seems like I also need to run increment on one or more achievements before it gets refreshed. In either case it is still an improvement, as it was not working at all before.

Related

App freezes on splash screen for some users

Some users report an issue: they launch the app, the splash screen appears, but nothing else happens. Splash screen just stays on without ANR or errors.
I can't see any logs because no loggers were initialized yet, and I don't even know if the onCreate method was called.
Important notes:
99% of users don't experience this
users that report such issue say that it's persistent - they can't use the app at all
some users say if they launch google play store first and then launch app - it works fine, but without that step it always freezes at the splash screen, so they have to launch google play store each time before launching the app
To send any data anywhere I need to initialize a bunch of dependencies, but looks like it doesn't even get to that point. App works fine on millions of devices, but a few thousand users reported this issue. Cannot post application initialization code as it's huge.
Questions:
What can possibly be the reason of this?
Where would be the best place to start searching for the bug?
Is there a way to determine the first line of code where the app is not launching as it should?
Is there something that the google play store triggers that applications need to launch properly?
It was because of googlePlayStoreAppUpdateManager.appUpdateInfo check for updates that returns a Task, but sometimes it doesn't actually call nor success nor fail listeners, so we hang forever. Solution was to add RxJava wrapper with timeout and limit waiting time for Google to answer to some reasonable time.
It looks like some devices, like Xiaomi or Honor are not allowing google play manager to check for updates unless explicitly started by the user, so this check should be done carefully.

Application restart

I have been running into a problem with my application, which I have no idea why. The following is:
the application is a large, commercial project, which makes several connections to the database, with a login system and everything else
I noticed that if I leave the app in the background for about 10 minutes, for example, it terminates my connection and restarts everything again, forcing me to log in again.
The only guarantee I can give is that they are not connection problems with my server, as in my tests it never failed.
Anyone who might have any idea why?
(I know that the explanation of the problem was a little vague, but the situation is very vague even for me)
How did I find my problem?
The user of my application was using a bluetooth barcode reader, which was programmed to automatically turn off after a period of inactivity. I noticed that whenever the bluetooth device turned off, my application would lose its previous state if it was in the background. Using the LogCat tool, I realized that my process was being killed by the system itself. The messages always looked like these:
W/ActivityManager: Force finishing activity
my.project/.view.activities.MyActivity
I/ActivityManager: Process my.project (pid 12984) has died
After much research, I found that the Android system interprets some external events as configuration changes, eg screen rotation change, Bluetooth device connection/disconnection, etc.
When such a change happens, Android, by default, kills your app's process and restarts it completely again, so that the app adapts to the new behavior. In my case, there was a NullPointerException in the code, which I hadn't handled correctly, so the application went back to the beginning, losing its state data.
However, in other application screens the mentioned Exception didn't occur (so it doesn't go back to login when starting), but even so I lost some screen data, like something that was typed in an EditText, for example.
How did I solve it?
On researching again, I found that you can let Android handle these configuration changes itself, telling it not to restart its process. To do this, just add in your Manifest, in the desired activity, the line:
android: configChanges = "keyboard | keyboardHidden | navigation"
As in my case the problem was with a bluetooth keyboard, I added these options keyboard | keyboardHidden; some keyboard models, for some reason, also change Android navigation, so I added navigation. After this change, done! No more problems!
P.S. 1: Unfortunately, not everything always works out. Adding android: configChanges won't work if your activity has fragments (I'm still trying to figure out how to solve this).
P.S. 2: This is not a good practice, I need to make that clear to you. For me, it's okay to do it this way, as my application responds well to changes. After all, my app is simple. Only use this feature that I explained if it is your last option or, if like me, your application is not so complex. Remember: this is not a magic solution to problems; in my specific case it worked fine, but for you, it might break your application.
P.S. 3: I recommend taking a look at https://developer.android.com/guide/topics/manifest/activity-element#config, in the android subtopic: configChanges. Listed are all the configuration changes a device can make.

Child mode for keeping my android app open?

I need to know how to keep the user (child in this case) from accidentally hitting the home button and others closing the app. I want a parent to be able to hand the baby the phone and as she/he taps it will make sounds. That's all. My little one is my beta tester and she keeps closing it unintentionally then getting mad. I'm using android studio with ics+ support.
Although it is possible by overriding the onPause() method, or relaunching the app when closed, both shown here.
I would recommend checking if the phone is running 5.0 or higher. If it is, then show how to use screen pinning, which requires the overview and back buttons to be held together for 5 seconds - something which a small child is unlikely to do.

Getting facebook deeplinks to work on emulator facebook android

The problem I'm trying to solve- I'm trying to get deep linking working, and testing it with Emulator. When clicking on posts, the links direct to the mobile web site. This is in the case of the user having permissions for the app, and the app is installed (on the emulator). In the Facebook app, it even acknowledges its out of date, but an upgrade (in app) crashes.
I also noticed that the Facebook app installed on the emulator is out of date (I installed it via adb install facebook.apk from github sdk).
SSO is working fine, and I have setup deeplinking effectively with iOS before (So I know how ti's supposed to work/test it, etc.). But the port to Android is being held back by this out of date 3rd party Facebook app. I'm assuming testing on device will solve it, because there the Facebook app will be the latest (which brings to mind- what if people haven't updated their android facebook app?).
My app settings:
I'd post code, but this seems to be pure integration and configuration issues.
Note: my app isn't published on Google Play, could that be the issue?
Also: maybe this is only testable on the device? My device is "in the mail" so trying to get this done with emulator as much as i can.
Update: Facebook told me that this requires the Facebook app 1.9.* which is not in the SDK. So, I got my hands on a device, and while I haven't solved it, at least the app bookmark functionality is working. Will update if/when I find the answer.
Update 11am: I finally got it to work!
I had to publish my app in the Play/Market.
Each time I tested, log out of FB-Android app, clear cache, and force stop. Acc.
to the documentation the bookmarks are cached. I also think the
facebook app-syncing occurs on launch, and never again. So if you
change anything in FB's app settings, you need to log out/clear
cache/stop for it to take in the fb android app.
Only one key worked, even though it says "hash" in the fb app settings, I think
my dev key was screwing things up. Double-confirm that your release
key is the same as the one listed in app settings.
The final secret sauce for me, was to turn off SSO and deeplinking, re-test
without anything set. Also, remove dev package from phone and
download from Play. (see: key mixups). then, I stepped back through
the configurations by first turning on SSO, testing, then turning on
the native deep linking.
Only works on real device, not emulator (unless you can get 1.9 installed on emulator, may work, did not go down that route to test)
Not sure if this matters, but it may: install app from Store/Play, not from Eclipse. Could be the key syncing thing.
I figured it out- involved doing the following:
I had to publish my app in the Play/Market.
Each time I tested, log out of FB-Android app, clear cache, and force stop. Acc. to the documentation the bookmarks are cached. I also think the facebook app-syncing occurs on launch, and never again. So if you change anything in FB's app settings, you need to log out/clear cache/stop for it to take in the fb android app.
Only one key worked, even though it says "hash" in the fb app settings, I think my dev key was screwing things up. Double-confirm that your release key is the same as the one listed in app settings.
The final secret sauce for me, was to turn off SSO and deeplinking, re-test without anything set. Also, remove dev package from phone and download from Play. (see: key mixups). then, I stepped back through the configurations by first turning on SSO, testing, then turning on the native deep linking.
Only works on real device, not emulator (unless you can get 1.9 installed on emulator, may work, did not go down that route to test)
Not sure if this matters, but it may: install app from Store/Play, not from Eclipse. Could be the key syncing thing.
Have you had a look at the troubleshooting tips for deep linking? (Sorry, have to ask.)
I'm wondering if perhaps the FB app on your device was not properly quit after the relevant setting changes.

Warning Android user that app update could lead to losing data from old app version?

I'm writing a game for Android. When the user completes a level, they can restart from the next level if they lose (i.e. I need to store an integer to remember which level they got to). If the app is interrupted during play, I save the world state to disk (this is complex state storing a map and game entities).
I'd like to keep my options open in the future for changing my game code and the way the world state is saved/stored. However, I must consider the scenario when a user has an old version of the world state on their phone because they were in the middle of a game, they upgrade the app and now the app cannot load the world state.
Having to write code to migrate the old version of the data to the new version of the data would be a pain if there's some way I can avoid this. It would be nice if I could somehow ask the user to finish their current game in progress before updating. Can this be done? Are there any other options?
I don't intend to do this often. I'd like to iteratively develop my game while getting some early feedback, but this is difficult if I must fix how the world state is saved and restored now.
I hope this doesn't seem a silly question, but on a PC or a console it's perfectly OK to have games that you cannot save during a game or you can only save between levels. I'm just finding Android a bit of a pain here as you must have a save game strategy for all games.
You cannot prevent a user from upgrading an app, and you cannot execute any code until your app is installed (or upgraded).
Quite frankly, losing data due to an upgrade is unacceptable. If you use an SQLiteOpenHelper, you automatically get nice hooks that help you with the upgrade process.
I understand that you have a pretty complex savegame setup, but try to keep it as flexible as possible to allow for easy upgrades. There are lots of techniques that help you with that.
And Android and PCs are just completely different - on a PC, you sit down and play for hours. On Android, you play real quick and then do something else. Or, you play and get a phone call and are forced to switch away from your game.

Categories

Resources