Android Activities only transient ??

28 views
Skip to first unread message

darky

unread,
Nov 10, 2017, 1:53:51 PM11/10/17
to android-platform
Recently, I experienced, that the onDestroy of an Activity is called very quickly..

In my Activity, I had a List with String items and for every String Item, I called a Service (let's call it workerService) that obtained the string via intent and did something with it. When finished, it broadcasted a message; that message was retrieved by the Activity
and in the onReceive, if there were any Strings left, I increased a counter variable and called the worker again with the new String. So, simply put , this should work. It's kinda loop - call the workerService as long as items are left in the list.
But - after the service was called, the Activity was destroyed by android (onDestroy log outout proved) and hence, when the broadcast was received, the array was null (empty) as was the counter variable in it's inital state.

I really wonder why android destroys the activity (the output of the activity is actually displayed onScreen and no buttons are pressed; the app is not modfied in any way at that moment, just the call (via menu) to initally trigger the workerService cycle)

Since this i obviously not the correct to do what I like to do - what would be a better way to realize a kind of queue to subsequently call serviced with different intent params?

thank you 1!! :)

christian
Reply all
Reply to author
Forward
0 new messages