We have an industrial-control app with a main screen containing buttons which launch Activities to control specific industrial processes. The app ships preloaded on a Android device (a Samsung phone) that is only used for this purpose.
In its original version on Android 2.36, API 8, it was still possible to disable the Home button, and we did so, so the user couldn't accidentally exit one of these process activities without going through the main screen. But since then we've upgraded to newer devices running Android 4.42, and to API 16 to take advantage of some newer features, so we can no longer disable the home button. (NB - there's an extensive discussion of the practical impossibility of blocking the Home Button post-API 16 all over SO, but chiefly How to disable Home and other system buttons in Android? and How to disable home button in Android like lock screen apps do? so I consider that question settled) That's OK as long as we can notify the industrial equipment on the other end of the WiFi connection that this has been done so it doesn't think the screen is still up.
So my question is - from my Activity, how can I tell that my Activity is being closed due to the Home button being pressed, and not just some event local to the app? In other words, if the Activity is being closed in the normal fashion it handles onPause() and onStop(), but it also handles those events when the Home button is pressed, so I do I disguish those cases?