Skip to content

Instantly share code, notes, and snippets.

@MCMXCIII
Created August 19, 2020 00:51
Show Gist options
  • Save MCMXCIII/b1fa1a2d78d6390a5929b57224d5885d to your computer and use it in GitHub Desktop.
Save MCMXCIII/b1fa1a2d78d6390a5929b57224d5885d to your computer and use it in GitHub Desktop.
package com.example.test;
import com.example.test.R;
import androidx.appcompat.app.AppCompatActivity;
import android.R;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
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 {
private WebView mywebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mywebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings= mywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mywebView.loadUrl("https://twitter.com");
// Line of Code for opening links in app
mywebView.setWebViewClient(new WebViewClient());
}
//Code For Back Button
@Override
public void onBackPressed() {
if(mywebView.canGoBack())
{
mywebView.goBack();
}
else
{
super.onBackPressed();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment