Hello all and thanks for reading.
This question is kind of a follow on question from my original post here. Main activity progress bars and strike through text reset after a period of app inactivity. However, I've now worked out what's going on but still need some advice on how to solve it.
Just to recap...
Basically I have written a media player app that uses a number of standard progress bars which are created programmatically underneath each track title in the playlist. Each progress bar tracks the progress of the song its sits underneath in the playlist.
I also use the following code in my manifest to make sure the app always returns to the same main activity.
现在我的问题是，当用户返回到主屏幕，然后重新登场，为期30至60分钟后，该应用程序虽然一切是因为它是 - 如果进度条是只有部分满（即跟踪已暂停或停止的一半），一下子跃升了100％。
Now the problem I have is that when the user returns to the home screen and then relaunches the app after a period of 30 to 60 minutes although everything else is as it was - if the progress bar was only partially full (i.e. the track has been paused or stopped halfway through) all of a sudden its jumped to 100%.
我发现，当应用程序缓存的过程中碰撞出榜单其他应用月底发生这种情况。即我可以重新创建问题马上通过暂停应用程序，然后打开其他应用程序的负载，然后回去吧。我还注意到，当它不再出现在缓存的进程列表的OnCreate也被调用，所以它看起来像应用程序已经被关闭，其本质上重新创建活动。但是，什么是奇怪的是，有$ P $进度条pviously被设置为某个值突然得到与设置为100％进度重建。进展
I discovered that this happens when the apps cached process is bumped off the end of the list by other apps. I.e. I can recreate the issue straight away by pausing the app and then opening loads of other apps and then going back to it. I also noticed that when it no longer appears in the cached process list "oncreate" also gets called so it looks like the app has been closed and its essentially recreating the activity. However, what is odd is that the progress bars that have previously been set to some value suddenly get recreated with progress set to 100%. Progress
Now if they are being recreated surely their progress should default to 0? I even tried setting the progress when they are created to 0 (i.e. myprogbar.setProgress=(0) but this seemed to make no difference.
a. Ensure that the progress bars are set to 0 when they are created?
b. Check during oncreate if the app is already running and destroy all previous versions of it?
c. Ensure that the app doesn't get dropped from the cached processes?
d. Some other way of solving the issue.
I appreciate I could probably create a loop that loops through the progress bars once they have been created and resets them but I'm trying to understand where the progress bars are getting this value of 100% and how this relates to the app being pushed out of the cached processes list.