In many apps (Calendar, Drive, Play Store) when you tap a button and enter a new activity, the icon in the title bar turns into a back button, but for the app I am making, i
You need to add the below mentioned code in the manifest file. Search for the activity in which you want to add the back arrow functionality. If you find the one then fine or create the activity
Then add the following three lines of code in between.
And don't forget to add this piece of code in onCreate(); method of your particular activity in which you need back arrow.
Toolbar toolbar = (Toolbar) findViewById(R.id.searchToolbar);
setSupportActionBar(toolbar);
try{
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}catch(NullPointerException e){
Log.e("SearchActivity Toolbar", "You have got a NULL POINTER EXCEPTION");
}
This is how i solved the problem. Thanks.