Closed erikswed closed 7 years ago
You can increase/decrease fragment priority by incrementing/decrementing in getBackPriority()
method.
public int getBackPriority() {
// little bit higher than normal priority
return NORMAL_BACK_PRIORITY + 1;
}
sorry I´m a noob I dont understand what is getting higher or lower , what is fragment priority?
Imagine you have 5 BackFragments
in your Activity
. Now when user hits hardware back button BackFragments
are ordered by priority and the one with highest priority is notified about back-press at first.
Thanks for taking your time, this was useful info. I just read about your github project from here this tutorial(you post in the comment section) http://vinsol.com/blog/2014/10/01/handling-back-button-press-inside-fragments/
It seams hard to get a handle on the currently active visible fragment. In the tutorial code above they solve it with the topmostFragment I think, does your library have similar functionality like topmostFragment detection
Sorry I missed your comment. You can simply use isResumed() method (https://developer.android.com/reference/android/app/Fragment.html#isResumed()) to detect if your fragment is currently active.
Thanks for interesting lib, How does this work: We support five fragment priorities for ordering back-pressed event delivery This should cover majority of use-cases. If you need more fine control over priorities, feel free to increase or decrease priority by number constant. Just keep increment/decrement under 100.
What am I increment/decrement?