When I press the back button, it returns to the main fragment
. I am viewing pdf with webview
. There are gifs in PDF. Clicking on these gifs opens in gif. When I press the back key, it goes to the application's home page, but I want it to stay in that fragment. I just want him out. When I press Backspace, I want to run the onBackPressed()
function below.
public class AntrenmanProgramFragment extends Fragment {
public void onBackPressed() {
SharedPreferences sharedPref = getActivity().getSharedPreferences("sharedPref",Context.MODE_PRIVATE);
final String loginAntreman = sharedPref.getString("backAntreman", "kayıt yok");
tab = getActivity().findViewById(R.id.tabLayout);
new Handler().postDelayed(
new Runnable(){
@Override
public void run() {
if (loginAntreman.equals("0")){
tab.getTabAt(0).select();
}
if (loginAntreman.equals("1")){
tab.getTabAt(1).select();
}
}
}, 100);
}
}