I have a mirroring of a website in WebView and I would like that when I press the ** Back ** button on the Smartphone, I would go back to the previous page. Currently if I press the ** Back ** button on the Smartphone, the application is minimized (It stays in the background). I do not know how to do this, can anyone help me?
MainActivity
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView wv = (WebView) findViewById(R.id.webview1);
wv.loadUrl("https://www.xxxx.com.br");
wv.setWebViewClient(new WebViewClient());
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(false);
Manifest
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_stat_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>