Handling Activity Back Button:
In Activity, we have a method called onBackPressed.
This method is called on clicking back button. To override functionality of back button, we override this method in Activity and provide our logic
Ex: public void onBackPressed(){
Toast.makeText(this, “Back button is clicked”, Toast.LENGTH_LONG).show();
}