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.
Related
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.
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.
I observed one behavior in fire stick, apps which are present in main screen are always calling onDestroy on app launch, which cause app to restart and not launch where user left off.
I checked with Netflix app, even there onDestroy gets called on launch but they are preserving state before app close, and so able to launch from last exit state.
My doubt is, why fire stick treats main screen apps differently? I searched but did not find proper answer. Mostly people talking about is memory getting full which is not the case here.
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.
I am developing an app which requires the gdk program to continue running as-is even after the device is removed from the head. Currently the program is paused when this happens seemingly by default, but I need the program to stay running because it is constantly uploading video. The desired result is that the program will continue to run and upload a video stream even if the glass is removed from the user's head.
What can I do to change this behavior?
thank you.
You probably want to perform the long running upload in a background service. Android's activity model makes it such that you can't really depend on the life of the activity to always be in the foreground and you need to use a service for tasks that shouldn't be paused.
Also if you have an activity you want to return to when you put Glass back on, ensure you specify android:immersive="true" within your declared <activity>. Without this, your activity could be completely destroyed when the screen turns off.