[mono-android] How to force an exit gracefully

Brian Long brian at blong.com
Wed Mar 30 10:09:51 EDT 2011


I'm tussling with the question of how best to force my app to exit
The flow is that after a splash screen, the main activity starts and
when (in OnResume) it detects a lack of user login, it launches the
login activity
While in the login screen, the user can press the back button, which
will go to the main activity and therefore be immediately bounced to
the login screen again
To avoid Back having effectively no function (in the user's eyes) I
figured maybe Back should just exit the app
Options seem to be:

System.Environment.Exit(0);

or

Process.KillProcess(Process.MyPid());

I've used the former thus far

However the log (below) seems to imply that maybe I'm being a little
harsh, with its doom-mongering comments about threads exiting without
being detached and premature finalization and signal termination and
so on.

Questions:

1) Am I going about this completely the wrong way, and should I be
taking a standard approach here that hasn't occurred to me?
2) Should I ignore the log messages and be happy that I can exit when
I want to ?
3) Why does MonoDroid keep posting a log message saying "signature" ?

Thanks for any advice on the matter

- Brian

INFO/monodroid(3281): Activating instance of type TimeSheet.SplashActivity
INFO/monodroid(3281): signature
INFO/ActivityManager(96): Displayed activity
com.blong.TimeSheet/timesheet.SplashActivity: 2696 ms (total 2696 ms)
INFO/ActivityManager(96): Starting activity: Intent {
cmp=com.blong.TimeSheet/timesheet.MainActivity }
INFO/monodroid(3281): Activating instance of type TimeSheet.MainActivity
INFO/monodroid(3281): signature
INFO/ActivityManager(96): Starting activity: Intent {
cmp=com.blong.TimeSheet/timesheet.LoginActivity }
INFO/monodroid(3281): Activating instance of type TimeSheet.LoginActivity
INFO/monodroid(3281): signature
INFO/ActivityManager(96): Displayed activity
com.blong.TimeSheet/timesheet.LoginActivity: 332 ms (total 520 ms)
DEBUG/dalvikvm(3281): threadid=7: thread exiting, not yet detached (count=0)
DEBUG/dalvikvm(3281): threadid=7: thread exiting, not yet detached (count=1)
ERROR/dalvikvm(3281): threadid=7: native thread exited without detaching
ERROR/dalvikvm(3281): VM aborting
WARN/mono(3281): Thread 0x0 may have been prematurely finalized
WARN/ContentService(96): binderDied() at ObserverNode name system
INFO/ActivityManager(96): Process com.blong.TimeSheet (pid 3281) has died.
INFO/WindowManager(96): WIN DEATH: Window{46c6b6d8
com.blong.TimeSheet/timesheet.LoginActivity paused=false}
ERROR/ActivityManager(96): fail to set top app changed!
DEBUG/Zygote(66): Process 3281 terminated by signal (11)
WARN/WindowManager(96): No focus window, dropping: KeyEvent{action=1
code=4 repeat=0 meta=0 scancode=158 mFlags=8}
INFO/UsageStats(96): Unexpected resume of com.htc.launcher while
already resumed in com.blong.TimeSheet


More information about the Monodroid mailing list