Reputation: 1345
According to my previous post, and some research online, I found out that the sytem might be playing the music even after the service's onDestroy was called because it was holding on to some resources like the MediaPlayer
, so I decided to actually kill the process instead of calling the stopForeground
or stopSelf
, because they simply are not working. However, I synced all the application states and called System.exit(0)
and it kills the foreground process as well as the activity as intended.
The only bit of confusion I had if System.exit(0)
killed the process and also freed the app resources? That is, does it release every bit of resource held by the app? I am worried about it because I don't need to call MediaPlayer.release()
and stopForeground()
and other similar cleanup methods, just one System.exit()
does the trick.
It's okay to call this for my app, because it triggers the behaviour I intend, but, I wonder if its okay for the android system, because lingering memories would be a bad thing. Thanks in advance, any insight would be helpful.
Upvotes: 1
Views: 794
Reputation: 184
does System.exit(int) kill the process and clear up all the resources?
Yes.
if System.exit(0) killed the process and also freed the app resources?
No. You should release resources gracefully when the app is closed.
Consider this situation:
System camera > System camera service <(server side|system level)---(app level|client side)> APP camera interface < APP uses camera resources.
System.exit() only release client side resource, but camera isn't release, it's not properly.
Upvotes: 1