Created
August 19, 2020 00:51
-
-
Save MCMXCIII/b1fa1a2d78d6390a5929b57224d5885d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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