I'm trying to customize onBackPress
behaviour of JetPack Navigation. Although I found the solution I'm just curious what's going behind the scenes in the following scenario:
Initial state of my activity is
MyActivity extends androidx.appcompat.app.AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getOnBackPressedDispatcher().addCallback(...); // <--- Method is unresolved
}
}
How come that after I add the following dependency to build.gradle the getOnBackPressedDispatcher()
method is being resolved:
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
What's going behind the scenes? Does it have something with the Jetifier? Does it alter the classes based on declared dependencies or something similar?