How come apps will sometimes refresh every single time I open them, even if I just switched between apps for a moment, but other times apps will stay exactly where I last scrolled to for a day or more?

666 views

How come apps will sometimes refresh every single time I open them, even if I just switched between apps for a moment, but other times apps will stay exactly where I last scrolled to for a day or more?

In: Technology

2 Answers

Anonymous 0 Comments

Depends on the coding of the app. Like people have different reactions to certain things. Apps are programmed to respond to certain events, click open scroll

Anonymous 0 Comments

Android developer here, with a bit of iOS experience.

TLDR: it’s up to the developer’s discretion, as we’re given the option to save everything just how you left it or to clear everything, depending on security or privacy concerns.

There’s a process called the app lifecycle that triggers when an app starts, stops, is moved to the background, or is stopped completely. There are lifecycle triggers developers can use to save or clear data when those events occur. That sequence is (roughly) create -> start -> resume and then pause -> stop -> destroy.

For instance, you launch a new application, which shows a home page you’ve previously logged into. In the process it fires the onCreate, onStart, and onResume triggers. The developer setup the foundation of their app in onCreate, checked storage for your credentials and logged you in during onStart, then started up small animation that plays on the page in onResume.

Now, you change applications, or just go back to the home screen. This fires the onPause trigger, which is the opposite of onResume. All the developer needs to do here is stop that animation from looping, because it would use unneeded resources to run in the background when you can’t even see it. Then the onStop trigger is fired, which is the opposite of onStart. The dev will save your credentials to storage, so you can be logged in when you go back to the app. But, the app is still running, so onDestroy (the opposite of onCreate) is never called.

Now, if the app we were writing was more secure, like a bank app, a trade platform, or even a diary, we may not want to leave you logged in, so in onStop we’ll log you out and clear your credentials, or at least flag you as needing to reauthenticate with biometrics to prevent someone from browsing your stuff when you put your phone down.