Adds history go back for webview activity when back key is pressed
This commit is contained in:
parent
4b7cfa07f2
commit
218a874830
|
@ -52,7 +52,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads;
|
|||
public class WebviewActivity extends AppCompatActivity {
|
||||
|
||||
private String url;
|
||||
|
||||
private WebView webView;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +74,7 @@ public class WebviewActivity extends AppCompatActivity {
|
|||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
WebView webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview);
|
||||
webView = Helper.initializeWebview(WebviewActivity.this, R.id.webview);
|
||||
|
||||
setTitle("");
|
||||
FrameLayout webview_container = (FrameLayout) findViewById(R.id.webview_container);
|
||||
|
@ -146,6 +146,15 @@ public class WebviewActivity extends AppCompatActivity {
|
|||
this.url = newUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (webView.canGoBack()){
|
||||
webView.goBack();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(){
|
||||
super.onDestroy();
|
||||
|
|
Loading…
Reference in New Issue