exception handling - How to determine if the Android Application was force closed? -


i need determine, if application force closed, crashed, or terminated normally. question is: how such thing in android environment. handling exceptions easy, need replace thread.setdefaultexceptionhandler. hard part is: how can distinguish force close shut down "normal" (like press, or home button + lots of time, etc)?

the reason is: can synchronize content of local database, server. , have reasons allow operation, in state 1, of main activity, , not in state 2. however, if user finds db related semantic error in program, in state 2 of main activity, or can stuck there.

we're prepared incoming call interruption, , other configuration changes, so, if application gets stuck in state 2, force closing app, reopening it, still leave user in stage 2, instead of stage 1.

so want leave way, user, after force closed stuck go stage 1, , able synchronize database, majority of or work can saved.

unfortunately there no way. when user or system force stops application, entire process killed. there no callback made inform has happened. ondestroy() not guaranteed called. documented in documentation: "there situations system kill activity's hosting process without calling method (or others) in ..."


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -