I recently started to program with Android studio, I came across a problem. I created a Webview application, and I would like to press the back button on the smartphone once you go back to the previously viewed page, while pressing it twice in a row will exit the application. For now I only managed to lock the back button. Do you have any advice? I am attaching the code written so far:
public class MainActivity extends AppCompatActivity {
@Override
public void onBackPressed() {
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView web=(WebView)findViewById(R.id.browser);
web.setWebViewClient(new WebViewClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("https://www.google.com");