Android Question Wierd activity behaviour - Sorry if its a bit vague

chris ash

Member
Licensed User
Longtime User
Hello

Sorry I have a bit of a vague question but i'm hoping you may be able to give some some steer as to where to look. If I can first explain the symptoms...

My application starts, the main activity creates, and then it resumes.

All good so far. If I then leave it after a random length of time the main activity will resume again (With no intervention from me). Thus refreshing the screen and restarting the audio. That's not so much of an issue but still should not be happening.

If however before this happens I click the play button which starts a new activity. This creates it resumes, and it plays... but then at a random point (even right in the middle of doing something) it will resume this activity. Which with the way it written returns you to the front screen again.

So from what I can make out the activities are resuming (as they should) and then resuming again.

Other things I know
It only happens once after a fresh install - Works fine forever and a day after that point
I cant say it ONLY happens on a Samsung device, but that device seems more prone (S7 FYI)
In debug mode it does not seem to do it - Only when released that does it

I'm really at a loss at to what could be causing it if anyone has any more ideas or needs any more info let me know. I'm honestly thinking its a Samsung thing just wondered if anyone had any ideas.

Once an activity has resumed why would it then resume again for no apparent reason? But only once the first time you run the app after and install / update?

Thanks
 

KMatle

Expert
Licensed User
Longtime User
See here: https://www.b4x.com/android/forum/threads/android-process-and-activities-life-cycle.6487/

Please think of the fact that Android ist the "master" and may do a lot of things to/with your app in the background which causes your app/activity to get paused and resumed. Sometimes it looks like for "no reason". In debug mode there are several instances which may cause this, too.

Be aware that apps can be killed by the OS at any time. Pressing the home button or when a device goes to sleep pauses the app. Evene some energy savings cause that.

That's the reason why there are service modules which will be running (see "start foreground" f.e.) or use "intents" which are triggers to start a service (like "when an sms arrives").
 
Upvote 0
Top