I have a main screen for my application, which then leads to different screens, and each of these strokes returns you to the main screen. I want to do some things every time the user "returns" to the main screen. How can I catch this kind of event?
Use the onResume () method in your main action or use the startActivityForResult method in your activity, overriding the keyDown method in routines, it can help you
you will try this:
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { //your stuff goes here } return super.onKeyDown(keyCode, event); }
You can do something like:
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // Do your stuff return true; } return super.onKeyDown(keyCode, event); }
Source: https://habr.com/ru/post/892400/More articles:CSS equivalent - htmlFind degrees (0-360ΒΊ) of a point on a circle - svgThe variable before or after the value in the IF expression - operatorsHow to get the "last sync" time for an account? - androidHow to represent time intervals in a schedule - javaRails optional /: local route - ruby-on-railsCXF Client Security - cxfUnderstanding the code: Hash, grep for duplicates (modified to check for multiple elements) - perlSleep flow boost for several nanoseconds - c ++What are the general rules for comparing different data types in C? - cAll Articles