I have an Android application that writes data to the SD card. I want to be able to see this data from my PC, when I connect via a USB cable. Unfortunately the application remains in the background when I quit it, and some system buffers do not get flushed properly (or at least I think that is what happens). As a result I cannot see the data properly, unless I manually force the application to stop. Then the data becomes visible on the PC, as if by magic.
I would like to have the program terminate automatically when I quit the main activity, or better still I would like to find some way to flush the system buffers. Does anyone have any ideas?
Do you close your file? Best would be in onPause() probably.
Check the activity lifecycle in http://developer.android.com/guide/topics/fundamentals.html
EDIT:
If you really feel you need to kill your process, you can use
android.os.Process.killProcess(android.os.Process.myPid());
or
System.exit(n)