Do not save operations
“Do not save operations” - the phrase “Do not keep activities” in the Android settings is translated in such a strange way. And the description “Delete all operations immediately after their completion by the user” does not add clarity. It is included in the Developer Options menu (at the very bottom).
This setting works very simply, when it is turned on, all inactive activites die. Those. after the transition from Activi A to Activi B, Activi A is destroyed. This way you can check how much your application fits into the
activity lifecycle .
I do not want to go into the details of the lifecycle, but, in a nutshell, the system kills the background activity when it wants. In reality, this is not so rare, so do not neglect it. For example, someone called you. During your conversation, the system can kill the activation of the application you just used.
')
Or, the easiest way to kill activites is to turn the screen (if not android: configChanges = "keyboardHidden | orientation | screenSize"). But not all applications support screen rotation. Yes, and those that support, are found with lifecycle errors at the design stage, so they should have no problems. The second simple way is to change the device language.
Well, of course, you can simply turn on "Do not keep activities".
I spent a few days fixing bugs after I went through my application with “Do not keep activities”. Now, I think you should always include this setting at design time. My main problem was the correct connection of social networks in the application.
Almost no problems with Vkontakte, with their SDK, you can write everything correctly, but they still have a small problem. Namely, after authorization through the application, the result is returned in onActivityResult. According to the documentation, you need to call
VKUIHelper.onActivityResult(requestCode, resultCode, data);
However, in the case of the destruction of our application's activation, the NPE will fly out, so you must first call
VKUIHelper.onResume(this);
Not entirely obvious, and undocumented. Started issue, on everyone.
There were problems with Facebook, because, because of my stupidity, I decided to use android-simple-facebook, and its author, as I understood, was not particularly steamed over the android lifecycle. I had to completely abandon it and redo everything on the official Facebook SDK and all the problems were gone. Although, probably, it was possible to fix everything in one line, but there was no going back.
And there were no problems with Twitter at all, because everything works just like an ax. They simply do not have their own SDK and authorization through the application. We have to do everything in the old fashioned way, through WebView. In general, they have the most terrible authorization of all.
Well, yes it is, lyrical digression.
There are problems with PayPal SDK, it just falls wherever possible. Fortunately, someone has already started the issue before me and for sure they will correct it in the near future.
Other examples
I do not have many applications on the phone, and I’m too lazy to watch them all, to be honest, but I could not get past the recently released Habr application. We begin, of course, with him. Well, I'll add a Payoneer error, which I found by chance :)
Habrahabr
I stumbled across different screens and was already upset, was it all written correctly and only I make so many mistakes. But no, I did get to the About page:
Caused by: java.lang.NullPointerException at ru.habrahabr.activity.about.AboutFragment.onAttach(AboutFragment.java:44)
Payoneer
Much time was not needed. Login screen, went to keepass for a password, returned - crash
plaster :
Caused by: java.lang.NullPointerException at com.payoneer.android.ui.fragment.LoginFragment.initializeOnCreateData(LoginFragment.java:379) at com.payoneer.android.ui.fragment.LoginFragment.onCreate(LoginFragment.java:152)
There are still some applications without crash, but with incorrect behavior, for example, the open fragment is not saved, but instead of it, after the re-creation, the main screen of the application is shown again.
PS
Use the setting “Do not keep activities”, I hope for someone this information will be new and will help to avoid mistakes of behavior and cracks.
I think I could also avoid a heap of reports on Google Play if I knew about this setting right away.
Oh yeah, the reports sent.