Check if back key was pressed in android?
android, back-button, java
Solution
A couple of ideas:
- You can just set a flag in `MainActivity` when it fires up `NewActivity`.
- You can call `startActivityForResult` from `MainActivity` and arrange for `NewActivity` to set a result, which you will receive in `MainActivity.onActivityResult()` when `NewActivity` finishes.
Problem
Say I'm on my main activity and I start a new activity ``` MainActivity > NewActivity ``` And from `NewActivity` I press the back key ``` MainActivity < NewActivity ``` I want `MainActivity` to do something if it's being displayed after `NewActivity` is closed, but not when `MainActivity` is run normally, such as when first running the application. Does anyone know if this is possible?